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



  • 相关阅读:
    MYSQL定时任务 触发器
    mybatis 学习
    SSM 记录
    环境变量配置
    servlet 拦截器 (filter)
    验证码
    jquery $.ajax({});参数详解
    maven打包忽略静态资源解决办法,dispatchServlet拦截静态资源请求的解决办法
    switch..case..
    HDU 1005 题解
  • 原文地址:https://www.cnblogs.com/rogerroddick/p/2846690.html
Copyright © 2011-2022 走看看