This function obtains extended information about the version of the operating system that is currently running. A remote application interface (RAPI) version of this function exists, and it is named CeGetVersionEx
At a Glance
Header file: | Winbase.h |
Windows CE versions: | 1.0 and later |
Syntax
BOOL GetVersionEx( LPOSVERSIONINFO lpVersionInformation );
Parameters
lpVersionInformation
[out] Pointer to an OSVERSIONINFO data structure that the function fills with operating system version information.
Before calling the GetVersionEx function, set the dwOSVersionInfoSize member of the OSVERSIONINFO data structure to sizeof(OSVERSIONINFO).
Return Values
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError. The function fails if you specify an invalid value for the dwOSVersionInfoSize member of the OSVERSIONINFO.
Remarks
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:
GetVersionEx (&osvi);
bIsWindows98orLater =
(osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
( (osvi.dwMajorVersion > 4) ||
( (osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0) ) );
Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. Rather than using GetVersionEx to determine the operating system platform or version number, test for the presence of the feature itself.
To determine the best way to test for a feature, refer to the documentation for the feature of interest. The following list discusses some common techniques for feature detection:
The value of the dwPlatformID member of the OSVERSIONINFO structure will be VER_PLATFORM_WIN32_CE.
When writing applications for Windows CE 2.01 running on a Japanese H/PC, be aware that the toolbar indicates that the version is 2.0.
For the Auto PC version 1.0, GetLastError returns of the following error values:
ERROR_INVALID_HANDLE
The supplied pointer is NULL.
ERROR_INVALID_DATA
The structure is not properly initialized; the size is set incorrectly.
See Also