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.
本文提供了一个C++示例程序,该程序使用GetVersionEx、GetSystemMetrics等函数来获取当前运行的操作系统的版本信息,并将这些信息显示在控制台上。此外,还介绍了如何通过调用GetFileVersionInfo函数获取完整版本号。
1422

被折叠的 条评论
为什么被折叠?



