zoukankan      html  css  js  c++  java
  • Operating System Version

    methods

    1. GetVersion

    DWORD WINAPI GetVersion(void);
    


    The following illustration shows the format of the bits in system version.
    +-------------+----------+-------------------------+
    |   Reserved  | Build Id |  Minor    |   Major     |
    +-------------+----------+-------------------------+
    31         30 29      16 15        8 7             0   bit

    example:

        DWORD dwVersion = 0;
        DWORD dwMajorVersion = 0;
        DWORD dwMinorVersion = 0;
        DWORD dwBuild = 0;
    
        dwVersion = GetVersion();
     
        // Get the Windows version.
    
        dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
        dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
    
        // Get the build number.
    
        if (dwVersion < 0x80000000)              
            dwBuild = (DWORD)(HIWORD(dwVersion));
        
    
        printf("Version is %d.%d (%d)\n", 
                    dwMajorVersion,
                    dwMinorVersion,
                    dwBuild);
    
    
    

    2. GetVersionEx function

    BOOL WINAPI GetVersionEx(
      __inout  LPOSVERSIONINFO lpVersionInfo
    );
    

    example:

    	OSVERSIONINFO _osv;
    	ZeroMemory(&_osv, sizeof(OSVERSIONINFO));
    	_osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    	::GetVersionEx(&_osv);
    	cout<<"Major:"<<_osv.dwMajorVersion<<endl;
    	cout<<"Minor:"<<_osv.dwMinorVersion<<endl;
    	cout<<"Build:"<<_osv.dwBuildNumber<<endl;
    	cout<<"Platform:"<<_osv.dwPlatformId<<endl;
    	cout<<"Others:"<<_osv.szCSDVersion<<endl;





    Reference

    The following table summarizes the most recent operating system version numbers.

    Operating systemVersion number
    Windows 8 6.2
    Windows Server 2012 6.2
    Windows 7 6.1
    Windows Server 2008 R2 6.1
    Windows Server 2008 6.0
    Windows Vista 6.0
    Windows Server 2003 R2 5.2
    Windows Server 2003 5.2
    Windows XP 5.1
    Windows 2000 5.0



  • 相关阅读:
    关于VS2010“ADO.NET Entity Data Model模板丢失或者添加失败问题
    Swagger的配置方法
    asp.net core的cookie认证
    abap程序开发
    闲置7成新二手图书处理(待更新)
    Winform 调用C++ OCX 传入参数和传出参数问题
    Html上传图片问题
    服务器端输出到客户端
    IE8下居然页面突然看不了
    解决Arial字体“高低肩问题”
  • 原文地址:https://www.cnblogs.com/rogerroddick/p/2846690.html
Copyright © 2011-2022 走看看