Added: OS.ComCtlVersion and OS.XPManifest properties
This commit is contained in:
parent
cdf35a6cdb
commit
6ea14fac77
@ -1,10 +1,10 @@
|
||||
object frmMain: TfrmMain
|
||||
Left = 199
|
||||
Top = 107
|
||||
Left = 339
|
||||
Top = 239
|
||||
BorderIcons = [biSystemMenu]
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'X'#178'Utils Test'
|
||||
ClientHeight = 206
|
||||
ClientHeight = 245
|
||||
ClientWidth = 455
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
@ -65,29 +65,44 @@ object frmMain: TfrmMain
|
||||
end
|
||||
object lblInstances: TLabel
|
||||
Left = 8
|
||||
Top = 84
|
||||
Top = 128
|
||||
Width = 49
|
||||
Height = 13
|
||||
Caption = 'Instances:'
|
||||
end
|
||||
object lblFormatSize: TLabel
|
||||
Left = 8
|
||||
Top = 160
|
||||
Top = 204
|
||||
Width = 56
|
||||
Height = 13
|
||||
Caption = 'Format size:'
|
||||
end
|
||||
object lblFormatSizeValue: TLabel
|
||||
Left = 244
|
||||
Top = 160
|
||||
Top = 204
|
||||
Width = 205
|
||||
Height = 13
|
||||
AutoSize = False
|
||||
Caption = '<unknown>'
|
||||
end
|
||||
object lstInstances: TListBox
|
||||
object lblComCtlVersionValue: TLabel
|
||||
Left = 112
|
||||
Top = 84
|
||||
Width = 333
|
||||
Height = 13
|
||||
AutoSize = False
|
||||
Caption = '<unknown>'
|
||||
end
|
||||
object lblComCtlVersion: TLabel
|
||||
Left = 8
|
||||
Top = 84
|
||||
Width = 73
|
||||
Height = 13
|
||||
Caption = 'ComCtl version:'
|
||||
end
|
||||
object lstInstances: TListBox
|
||||
Left = 112
|
||||
Top = 128
|
||||
Width = 337
|
||||
Height = 65
|
||||
ItemHeight = 13
|
||||
@ -95,7 +110,7 @@ object frmMain: TfrmMain
|
||||
end
|
||||
object txtSize: TEdit
|
||||
Left = 112
|
||||
Top = 156
|
||||
Top = 200
|
||||
Width = 121
|
||||
Height = 21
|
||||
TabOrder = 1
|
||||
@ -103,11 +118,21 @@ object frmMain: TfrmMain
|
||||
end
|
||||
object chkBytes: TCheckBox
|
||||
Left = 112
|
||||
Top = 180
|
||||
Top = 224
|
||||
Width = 97
|
||||
Height = 17
|
||||
Caption = '&Keep bytes'
|
||||
TabOrder = 2
|
||||
OnClick = txtSizeChange
|
||||
end
|
||||
object chkXPManifest: TCheckBox
|
||||
Left = 112
|
||||
Top = 104
|
||||
Width = 337
|
||||
Height = 17
|
||||
Caption = 'XP Manifest'
|
||||
Checked = True
|
||||
State = cbChecked
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
|
@ -12,10 +12,13 @@ uses
|
||||
type
|
||||
TfrmMain = class(TForm, IX2InstanceNotifier)
|
||||
chkBytes: TCheckBox;
|
||||
chkXPManifest: TCheckBox;
|
||||
lblAppPath: TLabel;
|
||||
lblAppPathValue: TLabel;
|
||||
lblAppVersion: TLabel;
|
||||
lblAppVersionValue: TLabel;
|
||||
lblComCtlVersion: TLabel;
|
||||
lblComCtlVersionValue: TLabel;
|
||||
lblFormatSize: TLabel;
|
||||
lblFormatSizeValue: TLabel;
|
||||
lblInstances: TLabel;
|
||||
@ -40,6 +43,10 @@ uses
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
// 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}
|
||||
|
||||
{=============================== TfrmMain
|
||||
Initialization
|
||||
========================================}
|
||||
@ -47,10 +54,16 @@ procedure TfrmMain.FormCreate;
|
||||
begin
|
||||
Randomize();
|
||||
|
||||
lblAppPathValue.Caption := App.Path;
|
||||
lblAppVersionValue.Caption := App.FormatVersion();
|
||||
lblOSVersionValue.Caption := OS.FormatVersion();
|
||||
txtSize.Text := IntToStr(Random(MaxInt));
|
||||
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));
|
||||
|
||||
RegisterInstance(Self);
|
||||
end;
|
||||
|
@ -32,6 +32,5 @@
|
||||
-M
|
||||
-$M16384,1048576
|
||||
-K$00400000
|
||||
-LE"c:\program files\borland\delphi6\Projects\Bpl"
|
||||
-LN"c:\program files\borland\delphi6\Projects\Bpl"
|
||||
-DmadExcept
|
||||
-LE"c:\delphi6\Projects\Bpl"
|
||||
-LN"c:\delphi6\Projects\Bpl"
|
||||
|
@ -47,7 +47,7 @@ PackageDLLOutputDir=
|
||||
PackageDCPOutputDir=
|
||||
SearchPath=
|
||||
Packages=vcl;rtl;vclx;Indy60;madBasic_;madDisAsm_;dsnap;dbrtl;xmlrtl;inet;soaprtl
|
||||
Conditionals=madExcept
|
||||
Conditionals=
|
||||
DebugSourceDirs=
|
||||
UsePackages=0
|
||||
[Parameters]
|
||||
@ -56,6 +56,10 @@ HostApplication=
|
||||
Launcher=
|
||||
UseLauncher=0
|
||||
DebugCWD=
|
||||
[Language]
|
||||
ActiveLang=
|
||||
ProjectLang=
|
||||
RootDir=
|
||||
[Version Info]
|
||||
IncludeVerInfo=1
|
||||
AutoIncBuild=1
|
||||
@ -148,19 +152,3 @@ Item0=madExcept
|
||||
[HistoryLists\hlUnitAliases]
|
||||
Count=1
|
||||
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||
[Included Packages]
|
||||
C:\Program Files\Borland\Delphi6\Bin\dclstd60.bpl=Borland Standard Components
|
||||
c:\program files\borland\delphi6\Bin\dclsmpedit60.bpl=Borland Editor Script Enhancements
|
||||
F:\Delphi\Components\madCollection\madBasic\Delphi 6\madBasic_.bpl=madBasic 1.1f · www.madshi.net
|
||||
F:\Delphi\Components\madCollection\madDisAsm\Delphi 6\madDisAsm_.bpl=madDisAsm 2.0a · www.madshi.net
|
||||
F:\Delphi\Components\madCollection\madExcept\Delphi 6\madExcept_.bpl=madExcept 2.6a · www.madshi.net
|
||||
F:\Delphi\Components\madCollection\madExcept\Delphi 6\madExceptIde_.bpl=madExceptIde 1.0b · www.madshi.net
|
||||
F:\Delphi\Components\madCollection\madExcept\Delphi 6\madExceptWizard_.bpl=madExceptWizard 2.6 · www.madshi.net
|
||||
C:\Program Files\Borland\Delphi6\Bin\dcldb60.bpl=Borland Database Components
|
||||
c:\program files\borland\delphi6\Bin\dclnet60.bpl=Borland Internet Components
|
||||
c:\program files\borland\delphi6\Bin\dclsoap60.bpl=Borland SOAP Components
|
||||
c:\program files\borland\delphi6\Projects\Bpl\ColorPickerButtonD6.bpl=ColorPickerButton
|
||||
C:\Program Files\Borland\Delphi6\Bin\dclact60.bpl=Borland ActionBar Components
|
||||
c:\program files\borland\delphi6\Projects\Bpl\SysILS.bpl=(untitled)
|
||||
c:\program files\borland\delphi6\Projects\Bpl\videocap5.bpl=(untitled)
|
||||
c:\program files\borland\delphi6\Projects\Bpl\DragDropD6.bpl=Drag and Drop Component Suite
|
||||
|
@ -1,8 +1,6 @@
|
||||
program X2UtilsTest;
|
||||
|
||||
uses
|
||||
madExcept,
|
||||
madLinkDisAsm,
|
||||
Forms,
|
||||
X2UtOS in '..\X2UtOS.pas',
|
||||
X2UtApp in '..\X2UtApp.pas',
|
||||
|
71
X2UtOS.pas
71
X2UtOS.pas
@ -18,6 +18,13 @@ type
|
||||
TX2OSVersion = (osWin95, osWin98, osWinME, osWinNT3, osWinNT4,
|
||||
osWin2K, osWinXP, osWin2003, osUnknown);
|
||||
|
||||
//:$ Record to hold the Common Controls version
|
||||
TX2CCVersion = record
|
||||
Major: Cardinal;
|
||||
Minor: Cardinal;
|
||||
Build: Cardinal;
|
||||
end;
|
||||
|
||||
{
|
||||
:$ Contains extended version information for the Operating System
|
||||
}
|
||||
@ -46,10 +53,14 @@ type
|
||||
}
|
||||
TX2OS = class(TObject)
|
||||
private
|
||||
FCCVersion: TX2CCVersion;
|
||||
FVersion: TX2OSVersion;
|
||||
FVersionEx: TX2OSVersionEx;
|
||||
|
||||
function GetXPManifest(): Boolean;
|
||||
protected
|
||||
procedure GetVersion(); virtual;
|
||||
procedure GetCCVersion(); virtual;
|
||||
public
|
||||
constructor Create();
|
||||
destructor Destroy(); override;
|
||||
@ -59,6 +70,13 @@ type
|
||||
//:: OS' Build number.
|
||||
function FormatVersion(Build: Boolean = True): String;
|
||||
|
||||
//:$ Contains the Common Controls version
|
||||
property ComCtlVersion: TX2CCVersion read FCCVersion;
|
||||
|
||||
//:$ Checks if the application uses an XP manifest
|
||||
//:: If present, Common Controls version 6 or higher is available.
|
||||
property XPManifest: Boolean read GetXPManifest;
|
||||
|
||||
//:$ Contains the detected OS version
|
||||
property Version: TX2OSVersion read FVersion;
|
||||
|
||||
@ -72,6 +90,21 @@ implementation
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
const
|
||||
ComCtl32 = 'comctl32.dll';
|
||||
|
||||
type
|
||||
PDllVersionInfo = ^TDllVersionInfo;
|
||||
TDllVersionInfo = record
|
||||
cbSize: DWORD;
|
||||
dwMajorVersion: DWORD;
|
||||
dwMinorVersion: DWORD;
|
||||
dwBuildNumber: DWORD;
|
||||
dwPlatformID: DWORD;
|
||||
end;
|
||||
|
||||
TDllGetVersion = function(pdvi: PDllVersionInfo): HRESULT; stdcall;
|
||||
|
||||
var
|
||||
GOS: TX2OS;
|
||||
|
||||
@ -97,6 +130,7 @@ begin
|
||||
|
||||
FVersionEx := TX2OSVersionEx.Create();
|
||||
GetVersion();
|
||||
GetCCVersion();
|
||||
end;
|
||||
|
||||
destructor TX2OS.Destroy;
|
||||
@ -180,6 +214,43 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TX2OS.GetCCVersion;
|
||||
var
|
||||
DllGetVersion: TDllGetVersion;
|
||||
hLib: THandle;
|
||||
viVersion: TDllVersionInfo;
|
||||
|
||||
begin
|
||||
FillChar(FCCVersion, SizeOf(FCCVersion), #0);
|
||||
hLib := LoadLibrary(ComCtl32);
|
||||
|
||||
if hLib <> 0 then
|
||||
begin
|
||||
@DllGetVersion := GetProcAddress(hLib, 'DllGetVersion');
|
||||
if Assigned(DllGetVersion) then
|
||||
begin
|
||||
FillChar(viVersion, SizeOf(viVersion), #0);
|
||||
viVersion.cbSize := SizeOf(viVersion);
|
||||
|
||||
DllGetVersion(@viVersion);
|
||||
|
||||
with FCCVersion do
|
||||
begin
|
||||
Major := viVersion.dwMajorVersion;
|
||||
Minor := viVersion.dwMinorVersion;
|
||||
Build := viVersion.dwBuildNumber;
|
||||
end;
|
||||
end;
|
||||
|
||||
FreeLibrary(hLib);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TX2OS.GetXPManifest;
|
||||
begin
|
||||
Result := (FCCVersion.Major >= 6);
|
||||
end;
|
||||
|
||||
|
||||
function TX2OS.FormatVersion;
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user