// 头文件
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;
}