zoukankan      html  css  js  c++  java
  • VC++ 获取windows系统的版本类型

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

    Operating systemVersion numberdwMajorVersiondwMinorVersionOther
    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 等系统版本信息 写了个函数,实现如下:

    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";
    	}
    }
    

      

     

  • 相关阅读:
    AC620教程 第十五节 8位7段数码管驱动设计与验证
    解决NIOS II工程移动在磁盘上位置后project无法编译问题
    基于FPGA的XPT2046触摸控制器设计
    Altera SOPC FrameBuffer系统设计教程
    【小梅哥SOPC学习笔记】SOPC开发常见问题及解决办法集锦
    ChromeDriver的安装和使用
    Selenium的安装和使用
    Requests的安装和使用
    安装python3
    centos安装后的个人工具
  • 原文地址:https://www.cnblogs.com/JczmDeveloper/p/3513849.html
Copyright © 2011-2022 走看看