获取windows系统版本信息

来源:互联网 发布:做广告牌用什么软件 编辑:程序博客网 时间:2024/05/01 02:56

 

// 头文件

class SysInfo
{
private:
    SysInfo(void);
    ~SysInfo(void);
public:
    static const SysInfo& Instance();

    DWORD           GetFullVersion() const {return MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);}
    bool            IsXP() const {return (GetFullVersion() < 0x0600);} // cover Win5.1 and 5.2 alike
    bool            IsVista() const {return (GetFullVersion() == 0x0600);}
    bool            IsVistaOrLater() const {return (GetFullVersion() >= 0x0600);}
    bool            IsWin7() const {return (GetFullVersion() == 0x0601);}
    bool            IsWin7OrLater() const {return (GetFullVersion() >= 0x0601);}
private:
    OSVERSIONINFOEX         inf;
};

 

 

// 源文件

SysInfo::SysInfo(void)
{
    SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));
    inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    GetVersionEx((OSVERSIONINFO *)&inf);
}

SysInfo::~SysInfo(void)
{
}

const SysInfo& SysInfo::Instance()
{
    static SysInfo instance;
    return instance;
}

 

原创粉丝点击