2004-06-07 14:37:41 +00:00
|
|
|
unit FMain;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
Classes,
|
|
|
|
Controls,
|
|
|
|
Forms,
|
|
|
|
StdCtrls,
|
2004-06-07 15:31:14 +00:00
|
|
|
SysUtils,
|
2004-06-07 14:37:41 +00:00
|
|
|
X2UtSingleInstance;
|
|
|
|
|
|
|
|
type
|
|
|
|
TfrmMain = class(TForm, IX2InstanceNotifier)
|
2004-06-07 15:31:14 +00:00
|
|
|
chkBytes: TCheckBox;
|
2004-08-31 09:12:50 +00:00
|
|
|
chkXPManifest: TCheckBox;
|
2004-06-07 14:37:41 +00:00
|
|
|
lblAppPath: TLabel;
|
|
|
|
lblAppPathValue: TLabel;
|
|
|
|
lblAppVersion: TLabel;
|
|
|
|
lblAppVersionValue: TLabel;
|
2004-08-31 09:12:50 +00:00
|
|
|
lblComCtlVersion: TLabel;
|
|
|
|
lblComCtlVersionValue: TLabel;
|
2004-06-07 15:31:14 +00:00
|
|
|
lblFormatSize: TLabel;
|
|
|
|
lblFormatSizeValue: TLabel;
|
2004-06-07 14:37:41 +00:00
|
|
|
lblInstances: TLabel;
|
|
|
|
lblOSVersion: TLabel;
|
|
|
|
lblOSVersionValue: TLabel;
|
|
|
|
lstInstances: TListBox;
|
2004-06-07 15:31:14 +00:00
|
|
|
txtSize: TEdit;
|
2004-06-07 14:37:41 +00:00
|
|
|
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
procedure FormDestroy(Sender: TObject);
|
2004-06-07 15:31:14 +00:00
|
|
|
procedure txtSizeChange(Sender: TObject);
|
2004-06-07 14:37:41 +00:00
|
|
|
protected
|
|
|
|
// IX2InstanceNotifier implementation
|
|
|
|
procedure OnInstance(const ACmdLine: String);
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
|
|
X2UtApp,
|
2004-06-07 15:31:14 +00:00
|
|
|
X2UtOS,
|
|
|
|
X2UtStrings;
|
2004-06-07 14:37:41 +00:00
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
2004-08-31 09:12:50 +00:00
|
|
|
// If you have a WinXP.RES which holds the XP manifest, you will
|
|
|
|
// notice that the Common Controls version changes to 6 instead of 5.
|
|
|
|
{.$R WinXP.RES}
|
|
|
|
|
2004-06-07 14:37:41 +00:00
|
|
|
{=============================== TfrmMain
|
|
|
|
Initialization
|
|
|
|
========================================}
|
|
|
|
procedure TfrmMain.FormCreate;
|
|
|
|
begin
|
2004-06-07 15:31:14 +00:00
|
|
|
Randomize();
|
2004-08-31 09:12:50 +00:00
|
|
|
|
|
|
|
lblAppPathValue.Caption := App.Path;
|
|
|
|
lblAppVersionValue.Caption := App.FormatVersion();
|
|
|
|
lblOSVersionValue.Caption := OS.FormatVersion();
|
|
|
|
|
|
|
|
with OS.ComCtlVersion do
|
|
|
|
lblComCtlVersionValue.Caption := Format('%d.%d build %d', [Major, Minor,
|
|
|
|
Build]);
|
|
|
|
|
|
|
|
chkXPManifest.Checked := OS.XPManifest;
|
|
|
|
txtSize.Text := IntToStr(Random(MaxInt));
|
2004-06-07 14:37:41 +00:00
|
|
|
|
|
|
|
RegisterInstance(Self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmMain.FormDestroy;
|
|
|
|
begin
|
|
|
|
UnregisterInstance(Self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2004-06-07 15:31:14 +00:00
|
|
|
|
|
|
|
procedure TfrmMain.txtSizeChange;
|
|
|
|
var
|
|
|
|
iSize: Int64;
|
|
|
|
|
|
|
|
begin
|
|
|
|
if TryStrToInt64(txtSize.Text, iSize) then
|
|
|
|
lblFormatSizeValue.Caption := FormatSize(iSize, chkBytes.Checked)
|
|
|
|
else
|
|
|
|
lblFormatSizeValue.Caption := 'Not a valid integer.';
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2004-06-07 14:37:41 +00:00
|
|
|
{=============================== TfrmMain
|
|
|
|
IX2InstanceNotifier implementation
|
|
|
|
========================================}
|
|
|
|
procedure TfrmMain.OnInstance;
|
|
|
|
var
|
|
|
|
iParam: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
lstInstances.Items.Add('New instance found:');
|
|
|
|
|
|
|
|
for iParam := 0 to ParamCountEx(ACmdLine) do
|
|
|
|
lstInstances.Items.Add(' ' + ParamStrEx(ACmdLine, iParam));
|
|
|
|
|
|
|
|
lstInstances.ItemIndex := lstInstances.Items.Count - 1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|