The following example uses the GetVersionEx, GetSystemMetrics, GetProductInfo, and GetNativeSystemInfo functions to determine the version information of the currently running operating system. If compatibility mode is in effect, the example displays the operating system selected for application compatibility. The example displays the information to the console.
To obtain the full version number for the operating system, call the GetFileVersionInfo function on one of the system DLLs, such as Kernel32.dll, then call VerQueryValue to obtain the //StringFileInfo//<lang><codepage>//ProductVersion subblock of the file version information.
Relying on version information is not the best way to test for a feature. Instead, refer to the documentation for the feature of interest. For more information on common techniques for feature detection, see Operating System Version.
If you must require a particular operating system, be sure to use it as a minimum supported version, rather than design the test for the one operating system. This way, your detection code will continue to work on future versions of Windows.