Windows applications

GetVersionExA function

The GetVersionExA function retrieves version information about the current operating system. This function has been superseded by the VerifyVersionInfo function. For the latest information, see Operating system version.

Important

We recommend that you use the VerifyVersionInfo function to determine the version of the operating system. The GetVersionEx function is not reliable for determining the operating system version.

Syntax


BOOL GetVersionExA(
  [out] LPSYSTEM_INFO lpVersionInformation
);
            

Parameters

Parameter Description
lpVersionInformation A pointer to a SYSTEM_INFO structure that receives version information about the current operating system. Note that the dwOSMajorVersion, dwOSMinorVersion, dwBuildNumber, and wServicePackMajorVersion members of this structure are obsolete.

Return value

If the function succeeds, the return value is non-zero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The GetVersionEx function retrieves version information about the current operating system. This information includes the major and minor version numbers, the build number, a platform identifier, and the major and minor version numbers for the installed service pack.

The dwOSMajorVersion, dwOSMinorVersion, dwBuildNumber, and wServicePackMajorVersion members of the SYSTEM_INFO structure are obsolete. For a complete list of obsolete members, see the GetVersionEx function documentation.

For applications that need to detect the operating system version, it is strongly recommended that you use the VerifyVersionInfo function. This function allows you to check for specific operating system versions or version combinations, providing more robust and reliable detection.

Examples

For a sample code snippet demonstrating the use of GetVersionEx, refer to the Windows API Code Pack.