📄 test.cpp
字号:
_tcscat(sText, sBuf);
}
else
{
if (osvi.wEmulatedServicePackMinor)
_stprintf(sBuf, _T(" Service Pack:0.%d"), osvi.wEmulatedServicePackMinor);
}
_tcscat(sText, _T("\n"));
#endif
//CE does not really have a concept of an emulated OS so
//lets not bother displaying any info on this on CE
if (osvi.UnderlyingPlatform == COSVersion::WindowsCE)
_tcscpy(sText, _T("OS: "));
else
_tcscat(sText, _T("Underlying OS: "));
switch (osvi.UnderlyingPlatform)
{
case COSVersion::Dos:
{
_tcscat(sText, _T("DOS"));
break;
}
case COSVersion::Windows3x:
{
_tcscat(sText, _T("Windows"));
break;
}
case COSVersion::WindowsCE:
{
_tcscat(sText, _T("Windows CE"));
break;
}
case COSVersion::Windows9x:
{
if (os.IsWindows95(&osvi))
_stprintf(sBuf, _T("Windows 95"));
else if (os.IsWindows95SP1(&osvi))
_stprintf(sBuf, _T("Windows 95 SP1"));
else if (os.IsWindows95B(&osvi))
_stprintf(sBuf, _T("Windows 95 B [aka OSR2]"));
else if (os.IsWindows95C(&osvi))
_stprintf(sBuf, _T("Windows 95 C [aka OSR2.5]"));
else if (os.IsWindows98(&osvi))
_stprintf(sBuf, _T("Windows 98"));
else if (os.IsWindows98SP1(&osvi))
_stprintf(sBuf, _T("Windows 98 SP1"));
else if (os.IsWindows98SE(&osvi))
_stprintf(sBuf, _T("Windows 98 Second Edition"));
else if (os.IsWindowsME(&osvi))
_stprintf(sBuf, _T("Windows Millenium Edition"));
else
_stprintf(sBuf, _T("Windows \?\?"));
_tcscat(sText, sBuf);
break;
}
case COSVersion::WindowsNT:
{
if (os.IsNTPreWin2k(&osvi))
{
_tcscat(sText, _T("Windows NT"));
if (os.IsNTWorkstation(&osvi))
_tcscat(sText, _T(" (Workstation)"));
else if (os.IsNTStandAloneServer(&osvi))
_tcscat(sText, _T(" (Server)"));
else if (os.IsNTPDC(&osvi))
_tcscat(sText, _T(" (Primary Domain Controller)"));
else if (os.IsNTBDC(&osvi))
_tcscat(sText, _T(" (Backup Domain Controller)"));
if (os.IsNTDatacenterServer(&osvi))
_tcscat(sText, _T(", (Datacenter)"));
else if (os.IsNTEnterpriseServer(&osvi))
_tcscat(sText, _T(", (Enterprise)"));
}
else if (os.IsWindows2000(&osvi))
{
_tcscat(sText, _T("Windows 2000"));
if (os.IsWin2000Professional(&osvi))
_tcscat(sText, _T(" (Professional)"));
else if (os.IsWin2000Server(&osvi))
_tcscat(sText, _T(" (Server)"));
else if (os.IsWin2000DomainController(&osvi))
_tcscat(sText, _T(" (Domain Controller)"));
if (os.IsWin2000DatacenterServer(&osvi))
_tcscat(sText, _T(", (Datacenter)"));
else if (os.IsWin2000AdvancedServer(&osvi))
_tcscat(sText, _T(", (Advanced Server)"));
}
else if (os.IsWindowsXPOrWindowsServer2003(&osvi))
{
if (os.IsStarterEditionInstalled(&osvi))
_tcscat(sText, _T("Windows XP (Starter Edition)"));
else if (os.IsXPPersonal(&osvi))
_tcscat(sText, _T("Windows XP (Personal)"));
else if (os.IsXPProfessional(&osvi))
_tcscat(sText, _T("Windows XP (Professional)"));
else if (os.IsWindowsServer2003(&osvi))
_tcscat(sText, _T("Windows Server 2003"));
else if (os.IsDomainControllerWindowsServer2003(&osvi))
_tcscat(sText, _T("Windows Server 2003 (Domain Controller)"));
else if (os.IsWindowsServer2003R2(&osvi))
_tcscat(sText, _T("Windows Server 2003 R2"));
else if (os.IsDomainControllerWindowsServer2003R2(&osvi))
_tcscat(sText, _T("Windows Server 2003 R2 (Domain Controller)"));
else
_tcscat(sText, _T("Windows \?\?"));
if (os.IsDatacenterWindowsServer2003(&osvi) || os.IsDatacenterWindowsServer2003R2(&osvi))
_tcscat(sText, _T(", (Datacenter Edition)"));
else if (os.IsEnterpriseWindowsServer2003(&osvi) || os.IsEnterpriseWindowsServer2003(&osvi))
_tcscat(sText, _T(", (Enterprise Edition)"));
else if (os.IsWebWindowsServer2003(&osvi) || os.IsWebWindowsServer2003R2(&osvi))
_tcscat(sText, _T(", (Web Edition)"));
else if (os.IsStandardWindowsServer2003(&osvi) || os.IsStandardWindowsServer2003R2(&osvi))
_tcscat(sText, _T(", (Standard Edition)"));
}
else if (os.IsWindowsVista(&osvi))
{
if (os.IsStarterEditionInstalled(&osvi))
_tcscat(sText, _T("Windows Vista (Starter Edition)"));
else if (os.IsHomeBasicInstalled(&osvi))
_tcscat(sText, _T("Windows Vista (Home Basic)"));
else if (os.IsHomeBasicPremium(&osvi))
_tcscat(sText, _T("Windows Vista (Home Premium)"));
else if (os.IsBusinessInstalled(&osvi))
_tcscat(sText, _T("Windows Vista (Business)"));
else if (os.IsEnterpriseInstalled(&osvi))
_tcscat(sText, _T("Windows Vista (Enterprise)"));
else if (os.IsUltimateInstalled(&osvi))
_tcscat(sText, _T("Windows Vista (Ultimate)"));
else
_tcscat(sText, _T("Windows Vista (\?\?)"));
}
else if (os.IsWindows7(&osvi))
{
if (os.IsStarterEditionInstalled(&osvi))
_tcscat(sText, _T("Windows 7 (Starter Edition)"));
else if (os.IsHomeBasicInstalled(&osvi))
_tcscat(sText, _T("Windows 7 (Home Basic)"));
else if (os.IsHomeBasicPremium(&osvi))
_tcscat(sText, _T("Windows 7 (Home Premium)"));
else if (os.IsBusinessInstalled(&osvi))
_tcscat(sText, _T("Windows 7 (Business)"));
else if (os.IsEnterpriseInstalled(&osvi))
_tcscat(sText, _T("Windows 7 (Enterprise)"));
else if (os.IsUltimateInstalled(&osvi))
_tcscat(sText, _T("Windows 7 (Ultimate)"));
else
_tcscat(sText, _T("Windows 7 (\?\?)"));
}
else if (os.IsWindowsServer2008(&osvi))
{
_tcscat(sText, _T("Windows Server 2008"));
if (os.IsDomainControllerWindowsServer2008(&osvi))
_tcscat(sText, _T(" (Domain Controller)"));
if (os.IsDatacenterWindowsServer2008(&osvi))
_tcscat(sText, _T(", (Datacenter Edition)"));
else if (os.IsEnterpriseWindowsServer2008(&osvi))
_tcscat(sText, _T(", (Enterprise Edition)"));
else if (os.IsWebWindowsServer2008(&osvi))
_tcscat(sText, _T(", (Web Edition)"));
else if (os.IsStandardWindowsServer2008(&osvi))
_tcscat(sText, _T(", (Standard Edition)"));
}
if (os.IsEnterpriseStorageServerInstalled(&osvi))
_tcscat(sText, _T(", (Storage Server Enterprise)"));
else if (os.IsExpressStorageServerInstalled(&osvi))
_tcscat(sText, _T(", (Storage Server Express)"));
else if (os.IsStandardStorageServerInstalled(&osvi))
_tcscat(sText, _T(", (Storage Server Standard)"));
else if (os.IsWorkgroupStorageServerInstalled(&osvi))
_tcscat(sText, _T(", (Storage Server Workgroup)"));
if (os.IsTerminalServicesInstalled(&osvi))
_tcscat(sText, _T(", (Terminal Services)"));
if (os.ISSmallBusinessServerInstalled(&osvi))
_tcscat(sText, _T(", (Small Business Server)"));
if (os.IsEmbedded(&osvi))
_tcscat(sText, _T(", (Embedded)"));
if (os.IsTerminalServicesInRemoteAdminMode(&osvi))
_tcscat(sText, _T(", (Terminal Services in Remote Admin Mode)"));
if (os.IsEmulated64Bit(&osvi))
_tcscat(sText, _T(", (64 Bit Edition)"));
if (os.IsMediaCenterInstalled(&osvi))
_tcscat(sText, _T(", (Media Center Edition)"));
if (os.IsTabletPCInstalled(&osvi))
_tcscat(sText, _T(", (Tablet PC Edition)"));
if (os.IsComputeClusterServerEditionInstalled(&osvi))
_tcscat(sText, _T(", (Compute Cluster Edition)"));
if (os.IsHomeServerEditionInstalled(&osvi))
_tcscat(sText, _T(", (Home Server Edition)"));
if (os.IsSecurityApplianceInstalled(&osvi))
_tcscat(sText, _T(", (Security Appliance)"));
if (os.IsBackOfficeInstalled(&osvi))
_tcscat(sText, _T(", (BackOffice)"));
if (os.IsNEditionInstalled(&osvi))
_tcscat(sText, _T(", (N)"));
if (os.IsHyperVInstalled(&osvi))
_tcscat(sText, _T(", (HyperV)"));
if (os.IsServerCoreInstalled(&osvi))
_tcscat(sText, _T(", (Server Core)"));
if (os.IsUniprocessorFree(&osvi))
_tcscat(sText, _T(", (Uniprocessor Free)"));
if (os.IsUniprocessorChecked(&osvi))
_tcscat(sText, _T(", (Uniprocessor Checked)"));
if (os.IsMultiprocessorFree(&osvi))
_tcscat(sText, _T(", (Multiprocessor Free)"));
if (os.IsMultiprocessorChecked(&osvi))
_tcscat(sText, _T(", (Multiprocessor Checked)"));
if (os.IsEssentialBusinessServerManagement(&osvi))
_tcscat(sText, _T(", (Windows Essential Business Server Manangement Server)"));
if (os.IsEssentialBusinessServerMessaging(&osvi))
_tcscat(sText, _T(", (Windows Essential Business Server Messaging Server)"));
if (os.IsEssentialBusinessServerSecurity(&osvi))
_tcscat(sText, _T(", (Windows Essential Business Server Security Server)"));
if (os.IsClusterServerInstalled(&osvi))
_tcscat(sText, _T(", (Cluster Server)"));
if (os.ISSmallBusinessServerPremiumInstalled(&osvi))
_tcscat(sText, _T(", (Small Business Server Premium)"));
break;
}
default:
{
_stprintf(sBuf, _T("Unknown OS"));
_tcscat(sText, sBuf);
break;
}
}
#ifndef UNDER_CE
switch (osvi.UnderlyingProcessorType)
{
case COSVersion::IA32_PROCESSOR:
{
_tcscat(sText, _T(", (x86-32 Processor)"));
break;
}
case COSVersion::MSIL_PROCESSOR:
{
_tcscat(sText, _T(", (MSIL Processor)"));
break;
}
case COSVersion::MIPS_PROCESSOR:
{
_tcscat(sText, _T(", (MIPS Processor)"));
break;
}
case COSVersion::ARM_PROCESSOR:
{
_tcscat(sText, _T(", (ARM Processor)"));
break;
}
case COSVersion::SHX_PROCESSOR:
{
_tcscat(sText, _T(", (SHX Processor)"));
break;
}
case COSVersion::ALPHA_PROCESSOR:
{
_tcscat(sText, _T(", (Alpha Processor)"));
break;
}
case COSVersion::PPC_PROCESSOR:
{
_tcscat(sText, _T(", (PPC Processor)"));
break;
}
case COSVersion::IA64_PROCESSOR:
{
_tcscat(sText, _T(", (IA64 Itanium[2] Processor)"));
break;
}
case COSVersion::AMD64_PROCESSOR:
{
_tcscat(sText, _T(", (x86-64 Processor)"));
break;
}
case COSVersion::UNKNOWN_PROCESSOR: //deliberate fallthrough
default:
{
_tcscat(sText, _T(", (Unknown Processor)"));
break;
}
}
#endif
_stprintf(sBuf, _T(" v%d."), osvi.dwUnderlyingMajorVersion);
_tcscat(sText, sBuf);
if (osvi.dwUnderlyingMinorVersion % 10)
{
if (osvi.dwUnderlyingMinorVersion > 9)
_stprintf(sBuf, _T("%02d"), osvi.dwUnderlyingMinorVersion);
else
_stprintf(sBuf, _T("%01d"), osvi.dwUnderlyingMinorVersion);
}
else
_stprintf(sBuf, _T("%01d"), osvi.dwUnderlyingMinorVersion / 10);
_tcscat(sText, sBuf);
if (osvi.dwUnderlyingBuildNumber)
{
_stprintf(sBuf, _T(" Build:%d"), osvi.dwUnderlyingBuildNumber);
_tcscat(sText, sBuf);
}
if (osvi.wUnderlyingServicePackMajor)
{
if (osvi.wUnderlyingServicePackMinor)
{
//Handle the special case of NT 4 SP 6a which Dtwinver ver treats as SP 6.1
if (os.IsNTPreWin2k(&osvi) && (osvi.wUnderlyingServicePackMajor == 6) && (osvi.wUnderlyingServicePackMinor == 1))
_stprintf(sBuf, _T(" Service Pack: 6a"));
//Handle the special case of XP SP 1a which Dtwinver ver treats as SP 1.1
else if (os.IsWindowsXP(&osvi) && (osvi.wUnderlyingServicePackMajor == 1) && (osvi.wUnderlyingServicePackMinor == 1))
_stprintf(sBuf, _T(" Service Pack: 1a"));
else
_stprintf(sBuf, _T(" Service Pack:%d.%d"), osvi.wUnderlyingServicePackMajor, osvi.wUnderlyingServicePackMinor);
}
else
_stprintf(sBuf, _T(" Service Pack:%d"), osvi.wUnderlyingServicePackMajor);
_tcscat(sText, sBuf);
}
else
{
if (osvi.wUnderlyingServicePackMinor)
_stprintf(sBuf, _T(" Service Pack:0.%d"), osvi.wUnderlyingServicePackMinor);
}
_tcscat(sText, _T("\n"));
//Some extra info for CE
#ifdef UNDER_CE
if (osvi.UnderlyingPlatform == COSVersion::WindowsCE)
{
_tcscat(sText, _T("Model: "));
_tcscat(sText, osvi.szOEMInfo);
_tcscat(sText, _T("\nDevice Type: "));
_tcscat(sText, osvi.szPlatformType);
}
#endif
}
else
_stprintf(sText, _T("Failed in call to GetOSVersion\n"));
#ifdef _WINDOWS
MessageBox(NULL, sText, _T("Operating System details"), MB_OK);
#elif _WIN32_WCE
MessageBox(NULL, sText, _T("Operating System details"), MB_OK);
#else
printf(sText);
#endif
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -