void CGetPCInfo::GetOS(string& os)
{
/*Windows 10 10.0* 10 0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2016 Technical Preview 10.0* 10 0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows 8.1 6.3* 6 3 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2012 R2 6.3* 6 3 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows 8 6.2 6 2 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2012 6.2 6 2 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows 7 6.1 6 1 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2008 R2 6.1 6 1 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Server 2008 6.0 6 0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Vista 6.0 6 0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2003 R2 5.2 5 2 GetSystemMetrics(SM_SERVERR2) != 0
Windows Server 2003 5.2 5 2 GetSystemMetrics(SM_SERVERR2) == 0
Windows XP 5.1 5 1 Not applicable
Windows 2000 5.0 5 0 Not applicable*/
OSVERSIONINFOEXA osvi;
BOOL bOsVersionInfoEx;
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
// If that fails, try using the OSVERSIONINFO structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXA));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
if( !(bOsVersionInfoEx = GetVersionExA ((OSVERSIONINFOA *) &osvi)) )
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOA);
if (! GetVersionExA ( (OSVERSIONINFOA *) &osvi) )
return;
}
switch (osvi.dwPlatformId)
{
// Test for the Windows NT product family.
case VER_PLATFORM_WIN32_NT:
{
// Test for the specific product.
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
os += "Windows Server 2003, ";
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
os += "Windows XP ";
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
os += "Windows 2000 ";
if ( osvi.dwMajorVersion <= 4 )
os += "Windows NT ";
// Test for specific product on Windows NT 4.0 SP6 and later.
if( bOsVersionInfoEx )
{
// Test for the workstation type.
if ( osvi.wProductType == VER_NT_WORKSTATION )
{
if( osvi.dwMajorVersion > 10 ) {
char szOs[80] = {0};
sprintf_s(szOs, 79, "Windows %d ", osvi.dwMajorVersion);
os += szOs;
} else if( osvi.dwMajorVersion == 10 )
os += "Windows 10 ";
else if( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion==3 )
os += "Windows 8.1 ";
else if( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion==2 )
os += "Windows 8 ";
else if( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion==1 )
os += "Windows 7 ";
else if( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion==0 )
os += "Windows Vista ";
else if( osvi.dwMajorVersion == 4 )
os += "Workstation 4.0 ";
else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
os += "Home Edition ";
else
os += "Professional ";
}
// Test for the server type.
else if ( osvi.wProductType == VER_NT_SERVER ||
osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
{
if( osvi.dwMajorVersion > 10 )
{
char szOs[80] = {0};
sprintf_s(szOs, 79, "Windows Server %d ", osvi.dwMajorVersion);
os += szOs;
} else if( osvi.dwMajorVersion == 10 )
os += "Windows Server 2016 Technical Preview ";
else if( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion==3 )
os += "Windows Server 2012 R2 ";
else if( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion==2 )
os += "Windows Server 2012 ";
else if( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion==1 )
os += "Windows Server 2008 R2 ";
else if( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion==0 )
os += "Windows Server 2008 ";
else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
os += "Datacenter Edition ";
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
os += "Enterprise Edition ";
else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
os += "Web Edition ";
else
os += "Standard Edition ";
}
else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
os += "Datacenter Server ";
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
os += "Advanced Server ";
else
os += "Server ";
}
else // Windows NT 4.0
{
if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
os += "Server 4.0, Enterprise Edition ";
else
os += "Server 4.0 ";
}
}
}
// Test for specific product on Windows NT 4.0 SP5 and earlier
else
{
HKEY hKey = NULL;
char szProductType[80] = {0};
DWORD dwBufLen=80;
LONG lRet = 0;
lRet = RegOpenKeyExA( HKEY_LOCAL_MACHINE,
"SYSTEM\CurrentControlSet\Control\ProductOptions",
0, KEY_QUERY_VALUE, &hKey );
if( lRet == ERROR_SUCCESS )
{
lRet = RegQueryValueExA( hKey, "ProductType", NULL, NULL,
(LPBYTE)szProductType, &dwBufLen);
szProductType[79] = 0;
RegCloseKey( hKey );
if ( lstrcmpiA( "WINNT", szProductType) == 0 )
os += "Workstation ";
if ( lstrcmpiA( "LANMANNT", szProductType) == 0 )
os += "Server ";
if ( lstrcmpiA( "SERVERNT", szProductType) == 0 )
os += "Advanced Server ";
}
}
// Display service pack (if any) and build number.
char szSrvPack[80] = {0};
if( osvi.dwMajorVersion == 4 &&
lstrcmpiA( osvi.szCSDVersion, "Service Pack 6" ) == 0 )
{
HKEY hKey = NULL;
LONG lRet = 0;
// Test for SP6 versus SP6a.
lRet = RegOpenKeyExA( HKEY_LOCAL_MACHINE,
"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\Q246009",
0, KEY_QUERY_VALUE, &hKey );
if( lRet == ERROR_SUCCESS )
sprintf_s( szSrvPack, 79, "Service Pack 6a (Build %d)", osvi.dwBuildNumber & 0xFFFF );
else // Windows NT 4.0 prior to SP6a
{
sprintf_s( szSrvPack, 79, "%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
}
RegCloseKey( hKey );
}
else // not Windows NT 4.0
{
sprintf_s( szSrvPack, 79, "%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
}
os += szSrvPack;
}
break;
// Test for the Windows Me/98/95.
case VER_PLATFORM_WIN32_WINDOWS:
{
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
{
os += "Windows 95 ";
if (osvi.szCSDVersion[1]=='C' || osvi.szCSDVersion[1]=='B')
os += "OSR2 ";
}
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
{
os += "Windows 98 ";
if ( osvi.szCSDVersion[1] == 'A' )
os += "SE ";
}
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
{
os += "Windows Millennium Edition";
}
}
break;
case VER_PLATFORM_WIN32s:
{
os += "Win32s";
}
break;
}
char szVer[80] = {0};
sprintf_s( szVer, 79, " %d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion );
os += szVer;
}
void CGetPCInfo::GetOS(string& os)
{
/*Windows