Initial Commit
This commit is contained in:
113
common/VERSION.HPP
Normal file
113
common/VERSION.HPP
Normal file
@@ -0,0 +1,113 @@
|
||||
#ifndef _COMMON_WINVERSIONINFO_HPP_
|
||||
#define _COMMON_WINVERSIONINFO_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
class WinVersionInfo : private OSVERSIONINFO
|
||||
{
|
||||
public:
|
||||
enum Platform{PlatformWin32s=VER_PLATFORM_WIN32s,PlatformWin32Windows=VER_PLATFORM_WIN32_WINDOWS,PlatformWin32NT=VER_PLATFORM_WIN32_NT};
|
||||
WinVersionInfo(void);
|
||||
virtual ~WinVersionInfo();
|
||||
DWORD majorVersion(void)const;
|
||||
DWORD minorVersion(void)const;
|
||||
DWORD buildNumber(void)const;
|
||||
Platform platformID(void)const;
|
||||
BOOL isWinNT(void)const;
|
||||
BOOL isWin95(void)const;
|
||||
String additionalInfo(void)const;
|
||||
private:
|
||||
WinVersionInfo(const WinVersionInfo &versionInfo);
|
||||
WinVersionInfo &operator=(const WinVersionInfo &versionInfo);
|
||||
void init(void);
|
||||
void getVersionEx(void);
|
||||
};
|
||||
|
||||
inline
|
||||
WinVersionInfo::WinVersionInfo(void)
|
||||
{
|
||||
init();
|
||||
getVersionEx();
|
||||
}
|
||||
|
||||
inline
|
||||
WinVersionInfo::WinVersionInfo(const WinVersionInfo &versionInfo)
|
||||
{ // private implementation
|
||||
*this=versionInfo;
|
||||
}
|
||||
|
||||
inline
|
||||
WinVersionInfo::~WinVersionInfo()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
WinVersionInfo &WinVersionInfo::operator=(const WinVersionInfo &/*versionInfo*/)
|
||||
{ // private implentation
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD WinVersionInfo::majorVersion(void)const
|
||||
{
|
||||
return OSVERSIONINFO::dwMajorVersion;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD WinVersionInfo::minorVersion(void)const
|
||||
{
|
||||
return OSVERSIONINFO::dwMinorVersion;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD WinVersionInfo::buildNumber(void)const
|
||||
{
|
||||
return OSVERSIONINFO::dwBuildNumber;
|
||||
}
|
||||
|
||||
inline
|
||||
WinVersionInfo::Platform WinVersionInfo::platformID(void)const
|
||||
{
|
||||
return Platform(OSVERSIONINFO::dwPlatformId);
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL WinVersionInfo::isWinNT(void)const
|
||||
{
|
||||
return PlatformWin32NT==platformID();
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL WinVersionInfo::isWin95(void)const
|
||||
{
|
||||
return PlatformWin32Windows==platformID();
|
||||
}
|
||||
|
||||
inline
|
||||
String WinVersionInfo::additionalInfo(void)const
|
||||
{
|
||||
if(OSVERSIONINFO::szCSDVersion&&*OSVERSIONINFO::szCSDVersion)return String(OSVERSIONINFO::szCSDVersion);
|
||||
return String();
|
||||
}
|
||||
|
||||
inline
|
||||
void WinVersionInfo::init(void)
|
||||
{
|
||||
OSVERSIONINFO::dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
|
||||
OSVERSIONINFO::dwMajorVersion=0;
|
||||
OSVERSIONINFO::dwMinorVersion=0;
|
||||
OSVERSIONINFO::dwBuildNumber=0;
|
||||
OSVERSIONINFO::dwPlatformId=0;
|
||||
OSVERSIONINFO::szCSDVersion[0]=0;
|
||||
}
|
||||
|
||||
inline
|
||||
void WinVersionInfo::getVersionEx(void)
|
||||
{
|
||||
::GetVersionEx(&((OSVERSIONINFO&)*this));
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user