|
How to Determine Windows Version Last updated: 7 January 2000 by Dolphinz SUMMARY
This article will explain how to get Microsoft® Windows
version installed on the system, using win32 assembly
languaje. THEORY
The GetVersionEx( ) function
supersedes the GetVersion( ) used on
windows 16 bits, so futher new programs should use the new function to get windows version information. THE CODE
The listing below provides the data needed to evaluate the
OSVERSIONINFO
structure which is filled by
GetVersionEx( ) function.
Now let's look to the elements of this structure: dwOSVersionInfoSize This member carries the memory size of the structure. You need to set this to SIZE OSVERSIONINFO before calling the function. dwMajorVersion Identifies the major version number of the operating system. dwMinorVersion Identifies the minor version number of the operating system. dwBuildNumber
Identifies the operating system platform, and it can be:
ANALIZING THE CODE
Now let's look at this piece of code which shows the usage of of the GetVersionEx( ) function in assembly languaje:
At this point, if the call to GetVersionEx() was successful, that's the return value is different than NULL, then we have at OSVERSIONINFO data structure, the information required, so we can check the returned information. When using the GetVersionEx( ) function to determine whether your application is running on a particular version of the operating system, check for version numbers that are greater than or equal to the desired version numbers. This ensures that the test succeeds for later versions of the operating system. For example, if your application requires Windows 98, use the following test:
In order to check what type of Windows NT is installed on the system, we will have to access to the registry and check a key: In Windows 2000, this function returns more information than in other operating systems. To receive this extra information, you will use a new structure called OSVERSIONINFOEX. For more information about the OSVERSIONINFOEX data structure, refer to the documentation in the Windows 2000 SDK. |