Stef Merlijn
asked on
Get windows version
Hi,
Previously I asked a similar question in:
see: https://www.experts-exchange.com/questions/22069225/Windows-Vista-How-to-determine-which-operatingsystem-is-used.html?sfQueryTermInfo=1+getsystemtyp+server
I now would like to extend this function by adding Windows Server 2008.
At the below I found out that both Windows Vista an Windows Server 2008 have mayor-version = 6 and minor-version = 0.
see: http://msdn.microsoft.com/en-us/library/ms724832(VS.85).aspx
How can i determine which operatingsystem is actually used as detailed as possible?
Probably Windows 7 can also be detected?
Regards,
Stef
Previously I asked a similar question in:
see: https://www.experts-exchange.com/questions/22069225/Windows-Vista-How-to-determine-which-operatingsystem-is-used.html?sfQueryTermInfo=1+getsystemtyp+server
I now would like to extend this function by adding Windows Server 2008.
At the below I found out that both Windows Vista an Windows Server 2008 have mayor-version = 6 and minor-version = 0.
see: http://msdn.microsoft.com/en-us/library/ms724832(VS.85).aspx
How can i determine which operatingsystem is actually used as detailed as possible?
Probably Windows 7 can also be detected?
Regards,
Stef
ASKER
How can I get ProductType within Delphi?
Does anybody have a function that gives OS + Windows Edition?
Does anybody have a function that gives OS + Windows Edition?
Extracted from the link provided by SectorX4: "...on Windows Vista and Windows Server 2008 a new function is available in kernel32.dll, called GetProductInfo(). It retrieves the product type for the operating system on the local computer..."
ASKER
But how do I use it from within Delphi?
Here you have an example: http://www.delphi3000.com/printarticle.asp?ArticleID=5147
Very important: you need at least Windows Vista for this Windows API call to work, but the code provided in the example takes care of that already
Very important: you need at least Windows Vista for this Windows API call to work, but the code provided in the example takes care of that already
ASKER
twocandles:
Your solution seems to cover only Windows Vista and not all other windows versions.
I really prefer one unit/function that covers all.
Your solution seems to cover only Windows Vista and not all other windows versions.
I really prefer one unit/function that covers all.
In fact the final solution would be an improvement of your first solution. You use your previous solution to check the Windows major version. If it's below 6 then you already got the result. If it's 6 then you dinamically load GetProductInfo() to check the Product Type and get the result.
Hi Delphiwizard.
See if the following works for you/is what you're looking for. If you want it extended further - or changed to not using strings but some kind of enum - please say so.
See if the following works for you/is what you're looking for. If you want it extended further - or changed to not using strings but some kind of enum - please say so.
type
TMyOSVersionInfo = record
IsServerEdition: Boolean;
Is64BitSystem: Boolean;
sCompleteDesc: String;
sWindows: String;
sServicePack: String;
Major: Cardinal;
Minor: Cardinal;
Build: Cardinal;
Special: Cardinal;
ServicePackMajor: Cardinal;
ServicePackMinor: Cardinal;
end;
// ...
function GetOSInformation: TMyOSVersionInfo;
var
SysInfo: TSystemInfo;
VerInfo: TOSVersionInfoEx;
bExtendedInfo: Boolean;
const
PROCESSOR_ARCHITECTURE_AMD64 = $00000009;
VER_NT_WORKSTATION = $00000001;
VER_NT_DOMAIN_CONTROLLER = $00000002;
VER_NT_SERVER = $00000003;
VER_SUITE_BACKOFFICE = $00000004;
VER_SUITE_BLADE = $00000400;
VER_SUITE_COMPUTE_SERVER = $00004000;
VER_SUITE_DATACENTER = $00000080;
VER_SUITE_ENTERPRISE = $00000002;
VER_SUITE_EMBEDDEDNT = $00000040;
VER_SUITE_PERSONAL = $00000200;
VER_SUITE_SINGLEUSERTS = $00000100;
VER_SUITE_SMALLBUSINESS = $00000001;
VER_SUITE_SMALLBUSINESS_RESTRICTED = $00000020;
VER_SUITE_STORAGE_SERVER = $00002000;
VER_SUITE_TERMINAL = $00000010;
VER_SUITE_WH_SERVER = $00008000;
begin
Result.IsServerEdition := False;
Result.sWindows := 'Unknown';
Result.Special := 0;
Result.Major := 0;
Result.Minor := 0;
Result.Build := 0;
Result.ServicePackMajor := 0;
Result.ServicePackMinor := 0;
Result.IsServerEdition := False;
Result.Is64BitSystem := (SizeOf(Pointer)=8);
bExtendedInfo := True;
VerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfoEx);
if not (GetVersionEx(VerInfo)) then
begin
bExtendedInfo := False;
VerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if not (GetVersionEx(VerInfo)) then VerInfo.dwOSVersionInfoSize := 0;
end;
if not (VerInfo.dwOSVersionInfoSize=0) then
begin
Result.Major := VerInfo.dwMajorVersion;
Result.Minor := VerInfo.dwMinorVersion;
Result.Build := VerInfo.dwBuildNumber;
Result.IsServerEdition := ((VerInfo.dwPlatformId=VER_PLATFORM_WIN32_NT) and not (VerInfo.wProductType=VER_NT_WORKSTATION));
if (bExtendedInfo) then
begin
Result.ServicePackMajor := VerInfo.wServicePackMajor;
Result.ServicePackMinor := VerInfo.wServicePackMinor;
end;
GetSystemInfo(SysInfo);
case VerInfo.dwPlatformId of
VER_PLATFORM_WIN32s:
Result.sWindows := 'Windows 3.1';
VER_PLATFORM_WIN32_WINDOWS:
begin
if (Result.Major=4) and (Result.Minor=0) then
if (VerInfo.szCSDVersion[1]='C') or (VerInfo.szCSDVersion[1]='B') then
Result.sWindows := 'Windows 95 (Release 2)'
else
Result.sWindows := 'Windows 95'
else if (Result.Major=4) and (Result.Minor=10) and (VerInfo.szCSDVersion[1]='A') then
Result.sWindows := 'Windows 98 SE'
else if (Result.Major=4) and (Result.Minor=10) then
Result.sWindows := 'Windows 98'
else if (Result.Major=4) and (Result.Minor=90) then
Result.sWindows := 'Windows ME';
end;
VER_PLATFORM_WIN32_NT:
begin
if (VerInfo.dwMajorVersion=6) and (VerInfo.dwMinorVersion=0) and (VerInfo.wProductType=VER_NT_WORKSTATION) then
Result.sWindows := 'Windows Vista'
else if (VerInfo.dwMajorVersion=6) and (VerInfo.dwMinorVersion=0) and not (VerInfo.wProductType=VER_NT_WORKSTATION) then
Result.sWindows := 'Windows 2008 Server'
else if (VerInfo.dwMajorVersion=6) and (VerInfo.dwMinorVersion=1) and (VerInfo.wProductType=VER_NT_WORKSTATION) then
Result.sWindows := 'Windows 7'
else if (VerInfo.dwMajorVersion=6) and (VerInfo.dwMinorVersion=1) and not (VerInfo.wProductType=VER_NT_WORKSTATION) then
Result.sWindows := 'Windows 2008 Server (Release 2)'
else if (VerInfo.dwMajorVersion=5) and (VerInfo.dwMinorVersion=2) then
begin
if (VerInfo.wSuiteMask=VER_SUITE_WH_SERVER) then
Result.sWindows := 'Windows Home Server'
else if (VerInfo.wProductType=VER_NT_WORKSTATION) and (SysInfo.wProcessorArchitecture=PROCESSOR_ARCHITECTURE_AMD64) then
Result.sWindows := 'Windows XP Professional x64'
else
begin
if not (GetSystemMetrics(89)=0) then
Result.sWindows := 'Windows 2003 Server'
else
Result.sWindows := 'Windows 2003 Server (Release 2)';
end;
end
else if (VerInfo.dwMajorVersion=5) and (VerInfo.dwMinorVersion=1) and not (VerInfo.wProductType=VER_NT_WORKSTATION) then
Result.sWindows := 'Windows XP';
if (bExtendedInfo) then
begin
if (VerInfo.wProductType=VER_NT_WORKSTATION) and not (SysInfo.wProcessorArchitecture=PROCESSOR_ARCHITECTURE_AMD64) then
begin
case VerInfo.dwMajorVersion of
4: Result.sWindows := 'Windows NT 4.0 Workstation';
5:
begin
if (VerInfo.wSuiteMask and VER_SUITE_PERSONAL<>0) and (VerInfo.dwMinorVersion=1) then
Result.sWindows := 'Windows XP Home'
else
if (VerInfo.dwMinorVersion=1) then
Result.sWindows := 'Windows XP Professional'
else
Result.sWindows := 'Windows 2000 Professional';
end;
6: if (VerInfo.wSuiteMask and VER_SUITE_PERSONAL<>0) then Result.sWindows := 'Windows Vista Home';
end;
end
else if (VerInfo.wProductType=VER_NT_SERVER) or (VerInfo.wProductType=VER_NT_DOMAIN_CONTROLLER) then
begin
if (VerInfo.dwMajorVersion=6) and (VerInfo.dwMinorVersion=0) then
begin
if (VerInfo.wSuiteMask and VER_SUITE_DATACENTER<>0) then
Result.sWindows := 'Windows 2008 Server Datacenter'
else if (VerInfo.wSuiteMask and VER_SUITE_ENTERPRISE<>0) then
Result.sWindows := 'Windows 2008 Server Enterprise'
else
Result.sWindows := 'Windows 2008 Server'
end
else if (VerInfo.dwMajorVersion=5) and (VerInfo.dwMinorVersion=2) then
begin
if (VerInfo.wSuiteMask and VER_SUITE_DATACENTER<>0) then
Result.sWindows := 'Windows 2003 Server Datacenter'
else if (VerInfo.wSuiteMask and VER_SUITE_ENTERPRISE<>0) then
Result.sWindows := 'Windows 2003 Server Enterprise'
else if (VerInfo.wSuiteMask and VER_SUITE_BLADE<>0) then
Result.sWindows := 'Windows 2003 Server Web Edition'
else
Result.sWindows := 'Windows 2003 Server';
end
else if (VerInfo.dwMajorVersion=5) and (VerInfo.dwMinorVersion=0) then
begin
if (VerInfo.wSuiteMask and VER_SUITE_DATACENTER<>0) then
Result.sWindows := 'Windows 2000 Server Datacenter'
else if (VerInfo.wSuiteMask and VER_SUITE_ENTERPRISE<>0) then
Result.sWindows := 'Windows 2000 Server Enterprise'
else if (VerInfo.wSuiteMask and VER_SUITE_BLADE<>0) then
Result.sWindows := 'Windows 2000 Server Web Edition'
else
Result.sWindows := 'Windows 2000 Server';
end
else
begin
if (VerInfo.wSuiteMask and VER_SUITE_DATACENTER<>0) then
Result.sWindows := 'Windows NT 4.0 Server Datacenter'
else if (VerInfo.wSuiteMask and VER_SUITE_ENTERPRISE<>0) then
Result.sWindows := 'Windows NT 4.0 Server Enterprise'
else if (VerInfo.wSuiteMask and VER_SUITE_BLADE<>0) then
Result.sWindows := 'Windows NT 4.0 Server Web Edition'
else
Result.sWindows := 'Windows NT 4.0 Server';
end;
end;
end;
end;
else
Result.sWindows := Format('Unknown Platform ID (%d)', [VerInfo.dwPlatformId]);
end;
end;
Result.sServicePack := Format('%d.%d', [Result.ServicePackMajor, Result.ServicePackMinor]);
Result.sCompleteDesc := Format('%s (Build: %d', [Result.sWindows, Result.Build]);
if not (Result.ServicePackMajor=0) then
Result.sCompleteDesc := Result.sCompleteDesc + Format(' - Service Pack: %s', [Result.sServicePack]);
Result.sCompleteDesc := Result.sCompleteDesc + ')';
end;
ASKER
preppydude:
Your solution looks very promissing. Please give me some time te test it.
What I do miss is the division of Windows 7 into separate Editions.
But maybe this isn't available yet?
Your solution looks very promissing. Please give me some time te test it.
What I do miss is the division of Windows 7 into separate Editions.
But maybe this isn't available yet?
I'll get to that when i get home again.
@Delphiwizard:
This one should recognize various editions on Windows 2008 Server, Windows Vista and Windows 7. I haven't been able to test it, though, as I don't have any of them.
This one should recognize various editions on Windows 2008 Server, Windows Vista and Windows 7. I haven't been able to test it, though, as I don't have any of them.
function GetOSInformation: TMyOSVersionInfo;
var
SysInfo: TSystemInfo;
VerInfo: TOSVersionInfoEx;
bExtendedInfo: Boolean;
// Only available on Windows 2008, Vista, 7 (or better)
GetProductInfo: function(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion: DWORD; pdwReturnedProductType: PDWORD): BOOL; WINAPI;
dwMajor: DWORD;
dwMinor: DWORD;
dwSpMajor: DWORD;
dwSpMinor: DWORD;
pdwProductType: PDWORD;
const
PROCESSOR_ARCHITECTURE_AMD64 = $00000009;
VER_NT_WORKSTATION = $00000001;
VER_NT_DOMAIN_CONTROLLER = $00000002;
VER_NT_SERVER = $00000003;
VER_SUITE_BACKOFFICE = $00000004;
VER_SUITE_BLADE = $00000400;
VER_SUITE_COMPUTE_SERVER = $00004000;
VER_SUITE_DATACENTER = $00000080;
VER_SUITE_ENTERPRISE = $00000002;
VER_SUITE_EMBEDDEDNT = $00000040;
VER_SUITE_PERSONAL = $00000200;
VER_SUITE_SINGLEUSERTS = $00000100;
VER_SUITE_SMALLBUSINESS = $00000001;
VER_SUITE_SMALLBUSINESS_RESTRICTED = $00000020;
VER_SUITE_STORAGE_SERVER = $00002000;
VER_SUITE_TERMINAL = $00000010;
VER_SUITE_WH_SERVER = $00008000;
begin
Result.IsServerEdition := False;
Result.sWindows := 'Unknown';
Result.Special := 0;
Result.Major := 0;
Result.Minor := 0;
Result.Build := 0;
Result.ServicePackMajor := 0;
Result.ServicePackMinor := 0;
Result.IsServerEdition := False;
Result.Is64BitSystem := (SizeOf(Pointer)=8);
bExtendedInfo := True;
VerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfoEx);
if not (GetVersionEx(VerInfo)) then
begin
bExtendedInfo := False;
VerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if not (GetVersionEx(VerInfo)) then VerInfo.dwOSVersionInfoSize := 0;
end;
if not (VerInfo.dwOSVersionInfoSize=0) then
begin
Result.Major := VerInfo.dwMajorVersion;
Result.Minor := VerInfo.dwMinorVersion;
Result.Build := VerInfo.dwBuildNumber;
Result.IsServerEdition := ((VerInfo.dwPlatformId=VER_PLATFORM_WIN32_NT) and not (VerInfo.wProductType=VER_NT_WORKSTATION));
if (bExtendedInfo) then
begin
Result.ServicePackMajor := VerInfo.wServicePackMajor;
Result.ServicePackMinor := VerInfo.wServicePackMinor;
end;
GetSystemInfo(SysInfo);
case VerInfo.dwPlatformId of
VER_PLATFORM_WIN32s:
Result.sWindows := 'Windows 3.1';
VER_PLATFORM_WIN32_WINDOWS:
begin
if (Result.Major=4) and (Result.Minor=0) then
if (VerInfo.szCSDVersion[1]='C') or (VerInfo.szCSDVersion[1]='B') then
Result.sWindows := 'Windows 95 (Release 2)'
else
Result.sWindows := 'Windows 95'
else if (Result.Major=4) and (Result.Minor=10) and (VerInfo.szCSDVersion[1]='A') then
Result.sWindows := 'Windows 98 SE'
else if (Result.Major=4) and (Result.Minor=10) then
Result.sWindows := 'Windows 98'
else if (Result.Major=4) and (Result.Minor=90) then
Result.sWindows := 'Windows ME';
end;
VER_PLATFORM_WIN32_NT:
begin
if (VerInfo.wProductType=VER_NT_WORKSTATION) then
begin
if (VerInfo.dwMajorVersion=6) then
begin
if (VerInfo.dwMinorVersion=1) then
Result.sWindows := 'Windows 7'
else if (VerInfo.dwMinorVersion=0) then
Result.sWindows := 'Windows Vista';
GetProductInfo := GetProcAddress(GetModuleHandle('kernel32.dll'), 'GetProductInfo');
GetProductInfo(dwMajor, dwMinor, dwSpMajor, dwSpMinor, pdwProductType);
case DWORD(pdwProductType) of
1: Result.sWindows := Format('%s %s', [Result.sWindows, 'Ultimate']);
2: Result.sWindows := Format('%s %s', [Result.sWindows, 'Home Basic']);
3: Result.sWindows := Format('%s %s', [Result.sWindows, 'Premium']);
4: Result.sWindows := Format('%s %s', [Result.sWindows, 'Enterprise']);
5: Result.sWindows := Format('%s %s', [Result.sWindows, 'Home Basic N']);
6: Result.sWindows := Format('%s %s', [Result.sWindows, 'Business']);
11: Result.sWindows := Format('%s %s', [Result.sWindows, 'Starter']);
16: Result.sWindows := Format('%s %s', [Result.sWindows, 'Business N']);
26: Result.sWindows := Format('%s %s', [Result.sWindows, 'Premium N']);
27: Result.sWindows := Format('%s %s', [Result.sWindows, 'Enterprise N']);
28: Result.sWindows := Format('%s %s', [Result.sWindows, 'Ultimate N']);
else Result.sWindows := Format('%s %s', [Result.sWindows, '(unknown edition)']);
end;
end
else if (VerInfo.dwMajorVersion=5) then
begin
if (VerInfo.dwMinorVersion=2) and (SysInfo.wProcessorArchitecture=PROCESSOR_ARCHITECTURE_AMD64) then
Result.sWindows := 'Windows XP Professional x64'
else if (VerInfo.wSuiteMask and VER_SUITE_PERSONAL<>0) and (VerInfo.dwMinorVersion=1) then
Result.sWindows := 'Windows XP Home'
else
if (VerInfo.dwMinorVersion=1) then
Result.sWindows := 'Windows XP Professional'
else
Result.sWindows := 'Windows 2000 Professional';
end
else
Result.sWindows := Format('Windows NT %d.%d', [VerInfo.dwMajorVersion, VerInfo.dwMinorVersion]);
end else begin
if (VerInfo.dwMajorVersion=6) and (VerInfo.dwMinorVersion=0) then
begin
Result.sWindows := 'Windows 2008';
GetProductInfo := GetProcAddress(GetModuleHandle('kernel32.dll'), 'GetProductInfo');
GetProductInfo(dwMajor, dwMinor, dwSpMajor, dwSpMinor, pdwProductType);
case DWORD(pdwProductType) of
7: Result.sWindows := Format('%s %s Server', [Result.sWindows, 'Standard']);
8: Result.sWindows := Format('%s %s Server', [Result.sWindows, 'Datacenter']);
10: Result.sWindows := Format('%s %s Server', [Result.sWindows, 'Enterprise']);
12: Result.sWindows := Format('%s %s Server', [Result.sWindows, 'Datacenter']);
13: Result.sWindows := Format('%s %s Server', [Result.sWindows, 'Standard']);
14: Result.sWindows := Format('%s %s Server', [Result.sWindows, 'Enterprise']);
15: Result.sWindows := Format('%s %s Server', [Result.sWindows, 'Enterprise IA64']);
17: Result.sWindows := Format('%s %s Server', [Result.sWindows, 'Web']);
else Result.sWindows := Result.sWindows + ' Server (unknown edition)';
end;
end
else if (VerInfo.dwMajorVersion=5) and (VerInfo.dwMinorVersion=2) then
begin
if (VerInfo.wSuiteMask and VER_SUITE_DATACENTER<>0) then
Result.sWindows := 'Windows 2003 Server Datacenter'
else if (VerInfo.wSuiteMask and VER_SUITE_ENTERPRISE<>0) then
Result.sWindows := 'Windows 2003 Server Enterprise'
else if (VerInfo.wSuiteMask and VER_SUITE_BLADE<>0) then
Result.sWindows := 'Windows 2003 Server Web Edition'
else
Result.sWindows := 'Windows 2003 Server';
end
else if (VerInfo.dwMajorVersion=5) and (VerInfo.dwMinorVersion=2) then
begin
if (VerInfo.wSuiteMask=VER_SUITE_WH_SERVER) then
Result.sWindows := 'Windows Home Server'
else
begin
if not (GetSystemMetrics(89)=0) then
Result.sWindows := 'Windows 2003 Server'
else
Result.sWindows := 'Windows 2003 Server (Release 2)';
end;
end
else if (VerInfo.dwMajorVersion=5) and (VerInfo.dwMinorVersion=0) then
begin
if (VerInfo.wSuiteMask and VER_SUITE_DATACENTER<>0) then
Result.sWindows := 'Windows 2000 Server Datacenter'
else if (VerInfo.wSuiteMask and VER_SUITE_ENTERPRISE<>0) then
Result.sWindows := 'Windows 2000 Server Enterprise'
else if (VerInfo.wSuiteMask and VER_SUITE_BLADE<>0) then
Result.sWindows := 'Windows 2000 Server Web Edition'
else
Result.sWindows := 'Windows 2000 Server';
end
else
begin
if (VerInfo.wSuiteMask and VER_SUITE_DATACENTER<>0) then
Result.sWindows := 'Windows NT 4.0 Server Datacenter'
else if (VerInfo.wSuiteMask and VER_SUITE_ENTERPRISE<>0) then
Result.sWindows := 'Windows NT 4.0 Server Enterprise'
else if (VerInfo.wSuiteMask and VER_SUITE_BLADE<>0) then
Result.sWindows := 'Windows NT 4.0 Server Web Edition'
else
Result.sWindows := 'Windows NT 4.0 Server';
end;
end;
end;
else
Result.sWindows := Format('Unknown Platform ID (%d)', [VerInfo.dwPlatformId]);
end;
end;
Result.sServicePack := Format('%d.%d', [Result.ServicePackMajor, Result.ServicePackMinor]);
Result.sCompleteDesc := Format('%s (Build: %d', [Result.sWindows, Result.Build]);
if not (Result.ServicePackMajor=0) then Result.sCompleteDesc := Result.sCompleteDesc + Format(' - Service Pack: %s', [Result.sServicePack]);
Result.sCompleteDesc := Result.sCompleteDesc + ')';
end;
ASKER
peppydude:
I've tried your code, but it isn't working yet.
-> VerInfo: TOSVersionInfoEx;
isn't recognized.
If i change it to
-> VerInfo: TOSVersionInfo;
it is recognized, but then
-> VerInfo.wServicePackMajor
-> VerInfo.wServicePackMinor
-> VerInfo.wProductType
-> VerInfo.wSuiteMask
are undeclared
I've tried your code, but it isn't working yet.
-> VerInfo: TOSVersionInfoEx;
isn't recognized.
If i change it to
-> VerInfo: TOSVersionInfo;
it is recognized, but then
-> VerInfo.wServicePackMajor
-> VerInfo.wServicePackMinor
-> VerInfo.wProductType
-> VerInfo.wSuiteMask
are undeclared
ASKER
Pervious problem is solved:
Adding the declaration in the code-part solves it.
Now I just need to know how to use it.
How do I get one or more values by f.e. clicking on a button?
procedure TForm1.Button1Click(Sender : TObject);
begin
// get Result.sWindows
end;
Adding the declaration in the code-part solves it.
Now I just need to know how to use it.
How do I get one or more values by f.e. clicking on a button?
procedure TForm1.Button1Click(Sender
begin
// get Result.sWindows
end;
type TOSVersionInfoEx = packed record
dwOSVersionInfoSize: DWORD;
dwMajorVersion: DWORD;
dwMinorVersion: DWORD;
dwBuildNumber: DWORD;
dwPlatformId: DWORD;
szCSDVersion: array[0..127] of AnsiChar;
wServicePackMajor: WORD;
wServicePackMinor: WORD;
wSuiteMask: WORD;
wProductType: Byte;
wReserved: Byte;
end;
ASKER
Another change in the code in order to get it working:
if not (GetVersionEx(VerInfo)) then
begin
bExtendedInfo := False;
VerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfoEx);
if not (GetVersionEx(VerInfo)) then
VerInfo.dwOSVersionInfoSize := 0;
end;
MUST BE:
if not GetVersionEx(TOSVersionInfo(Addr(VerInfo)^)) then
begin
bExtendedInfo := False;
VerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfoEx);
if not GetVersionEx(TOSVersionInfo(Addr(VerInfo)^)) then
VerInfo.dwOSVersionInfoSize := 0;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much.
ASKER
The original code doesn't had to be changed, but I lacked the following line in my code:
function GetVersionEx(var lpVersionInformation: TOSVersionInfoEx): BOOL; external kernel32 name 'GetVersionExW';
function GetVersionEx(var lpVersionInformation: TOSVersionInfoEx): BOOL; external kernel32 name 'GetVersionExW';
// Original code:
if not (GetVersionEx(VerInfo)) then
begin
bExtendedInfo := False;
VerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfoEx);
if not (GetVersionEx(VerInfo)) then
VerInfo.dwOSVersionInfoSize := 0;
end;
http://www.codeguru.com/cpp/w-p/system/systeminformation/print.php/c8973
You should be able to use that to determine the type.