汇集软件下载,免费分享活动线报

C++判断系统版本

微创网小编 0

很多时候我们要根据系统的不同版本进行不同的操作

下面给出了如何判断Windows操作系统的版本函数

int VRVGetSystemVersion(SYSTEM_VERSION *pnSystemVersion)
{ 
    OSVERSIONINFO osvi; 
    BOOL bOsVersionInfoEx;

   *pnSystemVersion = ENUM_SYSTEM_UNKOWN; 
    memset(&osvi, 0, sizeof(OSVERSIONINFO)); 
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

    if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi)) ) 
    { 
        osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 
        if (! GetVersionEx( (OSVERSIONINFO *) &osvi) ) 
        { 
            return FALSE; 
        } 
    }

    switch (osvi.dwPlatformId) 
    { 
        case VER_PLATFORM_WIN32_NT: 
            if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) 
            { 
                *pnSystemVersion = ENUM_SYSTEM_WIN_VISTA; 
            } 
 
            if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) 
            { 
                *pnSystemVersion = ENUM_SYSTEM_WIN_SER_2003; 
            } 
 
            if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) 
            { 
                *pnSystemVersion = ENUM_SYSTEM_WIN_XP; 
            } 
 
            if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) 
            { 
                *pnSystemVersion = ENUM_SYSTEM_WIN_2000; 
            } hackhp博客
 
            if ( osvi.dwMajorVersion <= 4) 
            { 
                *pnSystemVersion = ENUM_SYSTEM_WIN_NT; 
            } 
 
            if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1) 
            { 
                *pnSystemVersion = ENUM_SYSTEM_WIN_7; 
            } 
            break; 
        case VER_PLATFORM_WIN32_WINDOWS: 
            if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0 ) 
            { 
                *pnSystemVersion = ENUM_SYSTEM_WIN_95; 
            } 
 
            if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) 
            { 
                *pnSystemVersion = ENUM_SYSTEM_WIN_98; 
            } 
 
            if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) 
            { 
                *pnSystemVersion = ENUM_SYSTEM_WIN_ME; 
            } 
 
            break; 
        default: 
            *pnSystemVersion = ENUM_SYSTEM_UNKOWN; 
            break; 
 
    } 
    return TRUE; 
}

标签:

暂无标签

免责声明:

本站提供的资源,都来自网络,版权争议与本站无关,所有内容及软件的文章仅限用于学习和研究目的。不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负,我们不保证内容的长久可用性,通过使用本站内容随之而来的风险与本站无关,您必须在下载后的24个小时之内,从您的电脑/手机中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。侵删请致信E-mail: 1270528312@qq.com

同类推荐
评论列表
签到