Retrieves version information for the current operating system.
Syntax
BOOL GetVersionExA(
LPOSVERSIONINFOA lpVersionInformation
);
Parameters
| Type | Name | Description |
|---|---|---|
LPOSVERSIONINFOA |
lpVersionInformation |
A pointer to an OSVERSIONINFOA structure that receives the operating system version information.
|
Return value
If the function succeeds, the return value is a non-zero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
To get extended version information, use the GetVersionExW function or the VerifyVersionInfo function. For newer applications, consider using the GetVersion function instead.
Remarks
The GetVersionExA function populates the specified OSVERSIONINFOA structure with information about the operating system it is running on. The dwOSVersionInfoSize member of the structure must be set to the size, in bytes, of the OSVERSIONINFOA structure.
Use the information returned by GetVersionExA to determine the operating system and its version. For example, you can check the dwMajorVersion and dwMinorVersion members to identify the operating system version.
// Example of calling GetVersionExA
OSVERSIONINFOA osvi;
DWORD dwOsVer;
ZeroMemory(&osvi, sizeof(OSVERSIONINFOA));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
GetVersionExA(&osvi);
dwOsVer = osvi.dwMajorVersion << 8;
dwOsVer |= osvi.dwMinorVersion;
switch (dwOsVer) {
case 0x0601: // Windows 7
// ...
break;
case 0x0600: // Windows Vista
// ...
break;
case 0x0501: // Windows XP
// ...
break;
default:
// ...
break;
}
Requirements
| Header | sysinfoapi.h |
|---|---|
| Library | User32.lib |
| DLL | User32.dll |
See also
GetVersionGetVersionExWVerifyVersionInfoOSVERSIONINFOAOSVERSIONINFOEXA