Structure OSVERSIONINFOEX
This provides the following information:
- dwOSVersionInfoSize: Size of this data structure, in bytes. Set this member to sizeof(OSVERSIONINFOEX) before calling the GetVersionEx or VerifyVersionInfo function.
- dwMajorVersion: Major version number of the operating system.
- dwMinorVersion: Minor version number of the operating system.
- dwBuildNumber: Build number of the operating system.
- dwPlatformId: Operating system platform.
- szCSDVersion: Pointer to a null-terminated string, such as "Service Pack 3", that indicates the latest Service Pack installed on the system. If no Service Pack has been installed, the string is empty.
- wServicePackMajor: Major version number of the latest Service Pack installed on the system. For example, for Service Pack 3, the major version number is 3. If no Service Pack has been installed, the value is zero.
- wServicePackMinor: Minor version number of the latest Service Pack installed on the system. For example, for Service Pack 3, the minor version number is 0.
- wSuiteMask: Bit flags that identify the product suites available on the system.
- wProductType: Additional information about the system.
- wReserved: Reserved for future use.
For more, check MSDN.
Structure SYSTEM_INFO
This contains information about the system, such as arhitecture and type of processors. Of particular interest is the wProcessorArchitecture attribute that specifies, as the name implies, the processor architecture. According to MSDN, it can be one of the following:
- PROCESSOR_ARCHITECTURE_AMD64: for x64 AMND or Intel
- PROCESSOR_ARCHITECTURE_IA64: for Intel Itanium Processor Family (IPF)
- PROCESSOR_ARCHITECTURE_INTEL: for x86
- PROCESSOR_ARCHITECTURE_UNKNOWN: if the processor is not known
However, winnt.h lists several more constants for the architecture:
#define PROCESSOR_ARCHITECTURE_INTEL 0
#define PROCESSOR_ARCHITECTURE_MIPS 1
#define PROCESSOR_ARCHITECTURE_ALPHA 2
#define PROCESSOR_ARCHITECTURE_PPC 3
#define PROCESSOR_ARCHITECTURE_SHX 4
#define PROCESSOR_ARCHITECTURE_ARM 5
#define PROCESSOR_ARCHITECTURE_IA64 6
#define PROCESSOR_ARCHITECTURE_ALPHA64 7
#define PROCESSOR_ARCHITECTURE_MSIL 8
#define PROCESSOR_ARCHITECTURE_AMD64 9
#define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
For more, check MSDN.
GetProductInfo
This function is available only on Windows Vista and above. The WinNT.h header defines a list of possible product types:
#define PRODUCT_UNDEFINED 0x00000000
#define PRODUCT_ULTIMATE 0x00000001
#define PRODUCT_HOME_BASIC 0x00000002
#define PRODUCT_HOME_PREMIUM 0x00000003
#define PRODUCT_ENTERPRISE 0x00000004
#define PRODUCT_HOME_BASIC_N 0x00000005
#define PRODUCT_BUSINESS 0x00000006
#define PRODUCT_STANDARD_SERVER 0x00000007
#define PRODUCT_DATACENTER_SERVER 0x00000008
#define PRODUCT_SMALLBUSINESS_SERVER 0x00000009
#define PRODUCT_ENTERPRISE_SERVER 0x0000000A
#define PRODUCT_STARTER 0x0000000B
#define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C
#define PRODUCT_STANDARD_SERVER_CORE 0x0000000D
#define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E
#define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F
#define PRODUCT_BUSINESS_N 0x00000010
#define PRODUCT_WEB_SERVER 0x00000011
#define PRODUCT_CLUSTER_SERVER 0x00000012
#define PRODUCT_HOME_SERVER 0x00000013
#define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014
#define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015
#define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016
#define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017
#define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018
#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019
#define PRODUCT_UNLICENSED 0xABCDABCD
In Windows SDK for Windows 7 and Server 2008, there are additional products defined:
#define PRODUCT_HOME_PREMIUM_N 0x0000001A
#define PRODUCT_ENTERPRISE_N 0x0000001B
#define PRODUCT_ULTIMATE_N 0x0000001C
#define PRODUCT_WEB_SERVER_CORE 0x0000001D
#define PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E
#define PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F
#define PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020
#define PRODUCT_SERVER_FOUNDATION 0x00000021
#define PRODUCT_HOME_PREMIUM_SERVER 0x00000022
#define PRODUCT_SERVER_FOR_SMALLBUSINESS_V 0x00000023
#define PRODUCT_STANDARD_SERVER_V 0x00000024
#define PRODUCT_DATACENTER_SERVER_V 0x00000025
#define PRODUCT_ENTERPRISE_SERVER_V 0x00000026
#define PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027
#define PRODUCT_STANDARD_SERVER_CORE_V 0x00000028
#define PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029
#define PRODUCT_HYPERV 0x0000002A
#define PRODUCT_STORAGE_EXPRESS_SERVER_CORE 0x0000002B
#define PRODUCT_STORAGE_STANDARD_SERVER_CORE 0x0000002C
#define PRODUCT_STORAGE_WORKGROUP_SERVER_CORE 0x0000002D
#define PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE 0x0000002E
#define PRODUCT_STARTER_N 0x0000002F
#define PRODUCT_PROFESSIONAL 0x00000030
#define PRODUCT_PROFESSIONAL_N 0x00000031
#define PRODUCT_SB_SOLUTION_SERVER 0x00000032
#define PRODUCT_SERVER_FOR_SB_SOLUTIONS 0x00000033
#define PRODUCT_STANDARD_SERVER_SOLUTIONS 0x00000034
#define PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE 0x00000035
#define PRODUCT_SB_SOLUTION_SERVER_EM 0x00000036
#define PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM 0x00000037
#define PRODUCT_SOLUTION_EMBEDDEDSERVER 0x00000038
#define PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE 0x00000039
#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE 0x0000003F
#define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT 0x0000003B
#define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL 0x0000003C
#define PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC 0x0000003D
#define PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC 0x0000003E
#define PRODUCT_CLUSTER_SERVER_V 0x00000040
#define PRODUCT_EMBEDDED 0x00000041
#define PRODUCT_STARTER_E 0x00000042
#define PRODUCT_HOME_BASIC_E 0x00000043
#define PRODUCT_HOME_PREMIUM_E 0x00000044
#define PRODUCT_PROFESSIONAL_E 0x00000045
#define PRODUCT_ENTERPRISE_E 0x00000046
#define PRODUCT_ULTIMATE_E 0x00000047
For more info, check MSDN.
SystemInfo class
I've put together a class called SystemInfo that provides an easy way to retrieve the information about the operating system. Windows versions are defined in an enumeration in SystemInfo.h:
typedef enum WindowsVersion
{
Windows,
Windows32s,
Windows95,
Windows95OSR2,
Windows98,
Windows98SE,
WindowsMillennium,
WindowsNT351,
WindowsNT40,
WindowsNT40Server,
Windows2000,
WindowsXP,
WindowsXPProfessionalx64,
WindowsHomeServer,
WindowsServer2003,
WindowsServer2003R2,
WindowsVista,
WindowsServer2008,
WindowsServer2008R2,
Windows7,
};
Windows editions are defined in an additional enumeration called WindowsEdition.
typedef enum WindowsEdition
{
EditionUnknown,
Workstation,
Server,
AdvancedServer,
Home,
Ultimate,
HomeBasic,
HomePremium,
Enterprise,
HomeBasic_N,
Business,
StandardServer,
DatacenterServer,
SmallBusinessServer,
EnterpriseServer,
Starter,
DatacenterServerCore,
StandardServerCore,
EnterpriseServerCore,
EnterpriseServerIA64,
Business_N,
WebServer,
ClusterServer,
HomeServer,
StorageExpressServer,
StorageStandardServer,
StorageWorkgroupServer,
StorageEnterpriseServer,
ServerForSmallBusiness,
SmallBusinessServerPremium,
HomePremium_N,
Enterprise_N,
Ultimate_N,
WebServerCore,
MediumBusinessServerManagement,
MediumBusinessServerSecurity,
MediumBusinessServerMessaging,
ServerFoundation,
HomePremiumServer,
ServerForSmallBusiness_V,
StandardServer_V,
DatacenterServer_V,
EnterpriseServer_V,
DatacenterServerCore_V,
StandardServerCore_V,
EnterpriseServerCore_V,
HyperV,
StorageExpressServerCore,
StorageStandardServerCore,
StorageWorkgroupServerCore,
StorageEnterpriseServerCore,
Starter_N,
Professional,
Professional_N,
SBSolutionServer,
ServerForSBSolution,
StandardServerSolutions,
StandardServerSolutionsCore,
SBSolutionServer_EM,
ServerForSBSolution_EM,
SolutionEmbeddedServer,
SolutionEmbeddedServerCore,
SmallBusinessServerPremiumCore,
EssentialBusinessServerMGMT,
EssentialBusinessServerADDL,
EssentialBusinessServerMGMTSVC,
EssentialBusinessServerADDLSVC,
ClusterServer_V,
Embedded,
Starter_E,
HomeBasic_E,
HomePremium_E,
Professional_E,
Enterprise_E,
Ultimate_E
};
The declaration for class SystemInfo is shown here:
class SystemInfo
{
WindowsVersion m_nWinVersion;
WindowsEdition m_nWinEdition;
TCHAR m_szServicePack[128];
OSVERSIONINFOEX m_osvi;
SYSTEM_INFO m_SysInfo;
BOOL m_bOsVersionInfoEx;
private:
void DetectWindowsVersion();
void DetectWindowsEdition();
void DetectWindowsServicePack();
DWORD DetectProductInfo();
public:
SystemInfo();
virtual ~SystemInfo();
WindowsVersion GetWindowsVersion() const; // returns the windows version
WindowsEdition GetWindowsEdition() const; // returns the windows edition
bool IsNTPlatform() const; // true if NT platform
bool IsWindowsPlatform() const; // true is Windows platform
bool IsWin32sPlatform() const; // true is Win32s platform
DWORD GetMajorVersion() const; // returns major version
DWORD GetMinorVersion() const; // returns minor version
DWORD GetBuildNumber() const; // returns build number
DWORD GetPlatformID() const; // returns platform ID
void GetServicePackInfo(TCHAR* szServicePack) const;// additional information about service pack
bool Is32bitPlatform() const; // true if platform is 32-bit
bool Is64bitPlatform() const; // true if platform is 64-bit
};
The GetServicePackInfo() method must be provided with a parameter that is not NULL. It does not allocate memory if the parameter is NULL.
All you have to do is declare an object of type SystemInfo. The constructor calls a private method that retrieves the system information.
Comments
There are no comments yet. Be the first to comment!