写程序需要查看Windows的版本号来决定程序如何操作,看到MSDN的GetVersion 函数,这个函数返回一个DWORD的数据,然后自己对数据进行转换得到想要的具体值。 对应值如下:
转自MSDN的函数参考: GetVersion Function Operating System Version
GetVersion Function
Retrieves the version number of the current operating system. Note This function has been superseded by GetVersionEx. New applications should use GetVersionEx or VerifyVersionInfo. Syntax
C++
ParametersThis function has no parameters.Return ValueIf the function succeeds, the return value includes the major and minor version numbers of the operating system in the low-order word, and information about the operating system platform in the high-order word. For all platforms, the low-order word contains the version number of the operating system. The low-order byte of this word specifies the major version number, in hexadecimal notation. The high-order byte specifies the minor version (revision) number, in hexadecimal notation. The high-order bit is zero, the next 7 bits represent the build number, and the low-order byte is 5. RemarksThe GetVersionEx function was developed because many existing applications err when examining the packed DWORD value returned by GetVersion, transposing the major and minor version numbers. GetVersionEx forces applications to explicitly examine each element of version information.VerifyVersionInfo eliminates further potential for error by comparing the required system version with the current system version for you. ExamplesThe following code fragment illustrates how to extract information from the GetVersion return value:
The GetVersionEx function retrieves the major and minor version numbers and other information about the currently running version of the operating system. The VerifyVersionInfo function enables you to determine whether the current system satisfies a specified set of operating system version conditions. For more information, see the following topics:
The following table summarizes the most recent operating system version numbers.
Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. Rather than using GetVersionEx to determine the operating system platform or version number, test for the presence of the feature itself. To determine the best way to test for a feature, refer to the documentation for the feature of interest. The following list discusses some common techniques for feature detection:
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. Note that a 32-bit application can detect whether it is running under WOW64 by calling the IsWow64Process function. It can obtain additional processor information by calling the GetNativeSystemInfo function. 补充:
|