Getting the System Version(微软官方代码)

来源:互联网 发布:如何关闭mac上篮软件 编辑:程序博客网 时间:2024/05/16 16:03

The following example uses the GetVersionEx, GetSystemMetrics, GetProductInfo, and GetNativeSystemInfofunctions to determine the version information of the currently runningoperating system. If compatibility mode is in effect, the exampledisplays 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.