次の方法で共有


GetVersionEx (Compact 2013)

3/28/2014

This function obtains extended information about the version of the OS that is currently running.

Syntax

BOOL GetVersionEx( 
  LPOSVERSIONINFO lpVersionInformation
);

Parameters

  • lpVersionInformation
    [out] Pointer to an OSVERSIONINFO data structure that the function fills with version information.

    Before calling the GetVersionEx function, set the dwOSVersionInfoSize member of the OSVERSIONINFO data 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 dwOSVersionInfoSize member of the OSVERSIONINFO.

Remarks

When using the GetVersionEx function 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.

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 GetVersionEx to 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 LoadLibrary function to load the DLL. Then call the GetProcAddress function to determine whether the function of interest is present in the DLL. Use the pointer returned by GetProcAddress to 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 GetSystemMetrics function. 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 dwPlatformID member of the OSVERSIONINFO structure will be VER_PLATFORM_WIN32_CE.

Requirements

Header

winbase.h

Library

coredll.lib

See Also

Reference

System Management Functions
GetProcAddress
LoadLibrary
OSVERSIONINFO

Other Resources

GetSystemMetrics