Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function obtains extended information about the version of the OS that is currently running. CeGetVersionEx (RAPI)is the RAPI version of this function.
Syntax
BOOL GetVersionEx( LPOSVERSIONINFO lpVersionInformation ); |
Parameters
- lpVersionInformation
-
[out] Pointer to an OSVERSIONINFOdata structure that the function fills with version information.
Before calling the GetVersionExfunction, set the dwOSVersionInfoSizemember of the OSVERSIONINFOdata structure to sizeof(OSVERSIONINFO).
Return Value
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError. The function fails if you specify an invalid value for the dwOSVersionInfoSizemember of the OSVERSIONINFO.
Remarks
When using the GetVersionExfunction to determine whether your application is running on a particular version of the OS, check for version numbers that are greater than or equal to the version numbers you want. This verification ensures that the test succeeds for later versions of the OS. For example, you could use the following code example if your application requires Windows 98.
Copy Code | |
---|---|
GetVersionEx (&osvi); bIsWindows98orLater = (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && ( (osvi.dwMajorVersion > 4) || ( (osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0) ) ); |
Identifying the current OS is usually not the best way to determine whether a particular OS feature is present. This is because the OS may have had new features added in a redistributable dynamic-link library (DLL). Rather than using GetVersionExto determine the OS 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 you want. The following list discusses some common techniques for feature detection:
- You can test for the presence of the functions associated with
a feature.
To test for the presence of a function in a system DLL, call the LoadLibraryfunction to load the DLL. Then call the GetProcAddressfunction to determine whether the function of interest is present in the DLL. Use the pointer returned by GetProcAddressto call the function. Even if the function is present, it may be a stub that just returns an error code such as ERROR_CALL_NOT_IMPLEMENTED. - You can determine the presence of some features by using the
GetSystemMetricsfunction. For example, you can detect multiple
display monitors by calling
GetSystemMetrics(SM_CMONITORS).
- There are several versions of the redistributable DLLs that
implement shell and common control features.
The value of the dwPlatformIDmember of the OSVERSIONINFOstructure will be VER_PLATFORM_WIN32_CE.
Requirements
Header | winbase.h |
Library | coredll.lib |
Windows Embedded CE | Windows CE 1.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
See Also
Reference
System Management FunctionsGetProcAddress
LoadLibrary
OSVERSIONINFO
Other Resources
CeGetVersionEx (RAPI)GetSystemMetrics