Can anyone help me detect which version of Windows the user may be using?
I have seen some examples to do this, but they are not updated for Vista/7 Operating System
On XE2 a new class was introduced to deal with this: TOSVersion.
TOSVersion.Architecture
to check for 32 or 64 bit OS.TOSVersion.Platform
to check for Windows or Mac.TOSVersion.Major
and TOSVersion.Minor
for version numbers.TOSVersion.Name
to obtain the basic product name, e.g. Windows 7.TOSVersion.ToString
to obtain the full product name with version, e.g. Windows 7 Service Pack 1 (Version 6.1, Build 7601, 64-bit Edition).For older versions of Delphi I recommend the following:
In order to check for 2000, XP, Vista, 7 I suggest you read Win32MajorVersion and Win32MinorVersion.
The same information is available on MSDN, but the above came from my head!
If you are wanting very detailed product information then that takes a bit more work. Warren's answer gives one good route to obtaining that information. If you are wanting to test capability then version numbers are fine.
Use CheckWin32Version to check if the prevailing OS exceeds a certain version level. Although you should check that the function works correctly in your Delphi since the implementation of that function in Delphi 6 and earlier was incorrect.
To find out what the native OS architecture is (32 or 64 bit), use the GetNativeSystemInfo function. This function is not available on older operating systems so you should load it explicitly with GetProcAddress
. Test for wProcessorArchitecture=PROCESSOR_ARCHITECTURE_AMD64
to check for 64 bit OS.