VC++ 获取windows系统的版本类型

发布时间:2025-01-11 20:44

获取MCSE(微软认证解决方案专家)认证,精通Windows系统管理 #生活技巧# #工作学习技巧# #工作技能认证#

最新推荐文章于 2021-06-30 16:54:03 发布

Jakou 于 2018-01-29 11:30:08 发布

转载自:https://www.cnblogs.com/JczmDeveloper/p/3513849.html

vc中获取windows版本信息,一般是调用GetVersionEx 这个API函数来获取的,这个API需要OSVERSIONINFOEX 这个结构体作为参数,OSVERSIONINFOEX 的对应的具体的OS版本类型详细如下:

Operating system Version number dwMajorVersion dwMinorVersion Other Windows 8.1 6.3* 6 3 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION Windows Server 2012 R2 6.3* 6 3 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION Windows 8 6.2 6 2 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION Windows Server 2012 6.2 6 2 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION Windows 7 6.1 6 1 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION Windows Server 2008 R2 6.1 6 1 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION Windows Server 2008 6.0 6 0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION Windows Vista 6.0 6 0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION Windows Server 2003 R2 5.2 5 2 GetSystemMetrics(SM_SERVERR2) != 0 Windows Home Server 5.2 5 2 OSVERSIONINFOEX.wSuiteMask & VER_SUITE_WH_SERVER Windows Server 2003 5.2 5 2 GetSystemMetrics(SM_SERVERR2) == 0 Windows XP Professional x64 Edition 5.2 5 2 (OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION) && (SYSTEM_INFO.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) Windows XP 5.1 5 1 Not applicable Windows 2000 5.0 5 0 Not applicable

* For applications that have been manifested for Windows 8.1. Applications not manifested for 8.1 will return the Windows 8 OS version value (6.2). To 

 本人就获取 windows xp,vista,win8 ,win8.1 等系统版本信息 写了个函数,实现如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

VOID  GetOSVersion(CString& strOSVersion)

{

     OSVERSIONINFOEX osver = {0};

     osver.dwOSVersionInfoSize =  sizeof (osver);

     ::GetVersionEx((OSVERSIONINFO*)&osver);

     if ( osver.dwMajorVersion == 5

         && (osver.dwMinorVersion == 1 || osver.dwMinorVersion == 2)

         )

     {

         strOSVersion = L "OS:Windows XP" ;

     }

     else  if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0)

     {

         strOSVersion = L "OS:Windows Vista" ;

     }

     else  if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1)

     {

         strOSVersion = L "OS:Windows 7" ;

     }

     else  if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2)

     {

         strOSVersion = L "OS:Windows 8" ;

     }

     else  if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3)

     {

         strOSVersion = L "OS:Windows 8.1" ;

     }

}

网址:VC++ 获取windows系统的版本类型 https://www.yuejiaxmz.com/news/view/692808

相关内容

Windows 8 系统需求完整版
WINDOWS史前一万年
学习Windows操作系统的全面教程(掌握Windows操作系统,助力高效办公与日常生活)
Windows 系统不好用?让这些系统优化工具来调教它
微软正式推出Windows 11系统怎么升级?Windows 11系统有什么新功能
Windows 7 32位版本内存管理与优化指南
Windows 10 Manager v3.9.4 便携版
Windows 10 20H1新预览版18917推送:第二代Linux子系统上线
查看系统版本的cmd命令(解读快速查看系统版本号的三种方法)
Windows操作系统桌面清理攻略

随便看看