1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
type
TOSVERSIONINFOEX = record
dwOSVersionInfoSize: DWORD;
dwMajorVersion: DWORD;
dwMinorVersion: DWORD;
dwBuildNumber: DWORD;
dwPlatformId: DWORD;
szCSDVersion: array[0..127] of AnsiChar; { Maintenance string for PSS usage }
wServicePackMajor: WORD;
wServicePackMinor: WORD;
wSuiteMask: WORD;
wProductType: BYTE;
wReserved: BYTE;
end;
const
VER_SERVER_NT = DWORD($80000000);
{$EXTERNALSYM VER_SERVER_NT}
VER_WORKSTATION_NT = $40000000;
{$EXTERNALSYM VER_WORKSTATION_NT}
VER_SUITE_SMALLBUSINESS = $00000001;
{$EXTERNALSYM VER_SUITE_SMALLBUSINESS}
VER_SUITE_ENTERPRISE = $00000002;
{$EXTERNALSYM VER_SUITE_ENTERPRISE}
VER_SUITE_BACKOFFICE = $00000004;
{$EXTERNALSYM VER_SUITE_BACKOFFICE}
VER_SUITE_COMMUNICATIONS = $00000008;
{$EXTERNALSYM VER_SUITE_COMMUNICATIONS}
VER_SUITE_TERMINAL = $00000010;
{$EXTERNALSYM VER_SUITE_TERMINAL}
VER_SUITE_SMALLBUSINESS_RESTRICTED = $00000020;
{$EXTERNALSYM VER_SUITE_SMALLBUSINESS_RESTRICTED}
VER_SUITE_EMBEDDEDNT = $00000040;
{$EXTERNALSYM VER_SUITE_EMBEDDEDNT}
VER_SUITE_DATACENTER = $00000080;
{$EXTERNALSYM VER_SUITE_DATACENTER}
VER_SUITE_SINGLEUSERTS = $00000100;
{$EXTERNALSYM VER_SUITE_SINGLEUSERTS}
VER_SUITE_PERSONAL = $00000200;
{$EXTERNALSYM VER_SUITE_PERSONAL}
VER_SUITE_BLADE = $00000400;
{$EXTERNALSYM VER_SUITE_BLADE}
//
// RtlVerifyVersionInfo() os product type values
//
VER_NT_WORKSTATION = $0000001;
{$EXTERNALSYM VER_NT_WORKSTATION}
VER_NT_DOMAIN_CONTROLLER = $0000002;
{$EXTERNALSYM VER_NT_DOMAIN_CONTROLLER}
VER_NT_SERVER = $0000003;
{$EXTERNALSYM VER_NT_SERVER}
procedure AddString(var Dest: string; const Source: string; const LineFeed: boolean = True);
begin
if Dest = '' then
Dest:= Source
else
if LineFeed then
Dest:= Dest + #13#10 + Source
else Dest:= Dest + Source;
end;
procedure AddStrings(var Dest: string; const Header: string;
const Source: TStrings; const Prefix: string = ' ');
var
i: integer;
begin
if Source.Count = 1 then
begin
if Header <> '' then
AddString(Dest, Header + ' ' + Source[0])
else
AddString(Dest, Source[0]);
end
else
begin
if Header <> '' then
AddString(Dest, Header);
for i:=0 to Source.Count-1 do
AddString(Dest, Prefix + Source[i]);
end;
end;
function SystemVersionText: string;
type
THKEY = type Longword;
var
osvi: TOSVERSIONINFOEX;
bOsVersionInfoEx: boolean;
Key: HKEY;
szProductType : PChar;
dwBufLen: DWORD;
begin
result:= '';
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
// If that fails, try using the OSVERSIONINFO structure.
FillChar(osvi, SizeOf(TOSVERSIONINFOEX), 0);
osvi.dwOSVersionInfoSize:= SizeOf(TOSVERSIONINFOEX);
bOsVersionInfoEx:= GetVersionEx(POSVERSIONINFO(@osvi)^);
if not bOsVersionInfoEx then
begin
// If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
osvi.dwOSVersionInfoSize:= SizeOf(TOSVERSIONINFO);
if not GetVersionEx(POSVERSIONINFO(@osvi)^) then
exit;
end;
case osvi.dwPlatformId of
// Tests for Windows NT product family.
VER_PLATFORM_WIN32_NT:
begin
// Test for the product.
if osvi.dwMajorVersion <= 4 then
AddString(result, 'Microsoft Windows NT');
if (osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 0) then
AddString(result, 'Microsoft Windows 2000');
if bOsVersionInfoEx then // Use information from GetVersionEx.
begin
// Test for the workstation type.
if osvi.wProductType = VER_NT_WORKSTATION then
begin
if (osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 1) then
AddString(result, 'Microsoft Windows XP');
if (osvi.wSuiteMask and VER_SUITE_PERSONAL) <> 0 then
AddString(result, ' Home Edition', False)
else
AddString(result, ' Professional', False);
end
// Test for the server type.
else if osvi.wProductType = VER_NT_SERVER then
begin
if (osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 1) then
AddString(result, 'Microsoft Windows .NET');
if (osvi.wSuiteMask and VER_SUITE_DATACENTER) <> 0 then
AddString(result, ' DataCenter Server', False)
else if (osvi.wSuiteMask and VER_SUITE_ENTERPRISE) <> 0 then
if osvi.dwMajorVersion = 4 then
AddString(result, ' Advanced Server', False)
else
AddString(result, ' Enterprise Server', False)
else if osvi.wSuiteMask = VER_SUITE_BLADE then
AddString(result, ' Web Server', False)
else
AddString(result, ' Server', False);
end
end
else // Use the registry on early versions of Windows NT.
begin
RegOpenKeyEx(HKEY_LOCAL_MACHINE, 'SYSTEM\\CurrentControlSet\\Control\\ProductOptions',
0, KEY_QUERY_VALUE, Key );
szProductType:= StrAlloc(80);
RegQueryValueEx(Key, 'ProductType', Nil, Nil,
PByte(szProductType), @dwBufLen);
RegCloseKey(Key);
if szProductType = 'WINNT' then
AddString(result, ' Professional', False);
if szProductType = 'LANMANNT' then
AddString(result, ' Server', False);
if szProductType = 'SERVERNT' then
AddString(result, ' Advanced Server', False);
StrDispose(szProductType);
end;
// Display version, service pack (if any), and build number.
if osvi.dwMajorVersion <= 4 then
AddString(result, Format('version %d.%d %s (Build %d)',
[osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.szCSDVersion,
osvi.dwBuildNumber and $FFFF]))
else
AddString(result, Format('%s (Build %d)',
[osvi.szCSDVersion,
osvi.dwBuildNumber and $FFFF]));
end;
// Test for the Windows 95 product family.
VER_PLATFORM_WIN32_WINDOWS:
begin
if (osvi.dwMajorVersion = 4) and (osvi.dwMinorVersion = 0) then
begin
AddString(result, 'Microsoft Windows 95');
if (osvi.szCSDVersion[1] = 'C') or (osvi.szCSDVersion[1] = 'B') then
AddString(result, ' OSR2', False);
end;
if (osvi.dwMajorVersion = 4) and (osvi.dwMinorVersion = 10) then
begin
AddString(result, 'Microsoft Windows 98');
if osvi.szCSDVersion[1] = 'A' then
AddString(result, ' SE', False);
end;
if (osvi.dwMajorVersion = 4) and (osvi.dwMinorVersion = 90) then
AddString(result, 'Microsoft Windows Millennium Edition');
end;
end;
end; |
Partager