📄 test.cpp
字号:
#include <windows.h>
#if defined(_WIN32) || defined(_WIN64)
#include <tchar.h>
#endif
#include <memory.h>
#include <stdio.h>
#include <string.h>
#include "dtwinver.h"
#if !defined(_WIN32) && !defined(_WIN64)
#define _stprintf sprintf
#define _tcscat strcat
#define LPTSTR LPSTR
#endif
#if defined(_WINDOWS)
#if defined(_UNICODE)
LRESULT _stdcall wWinMain(HINSTANCE, HINSTANCE, LPWSTR, INT)
#else
#if defined _CONSOLE
void main()
#else
int PASCAL WinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
#endif //if defined _CONSOLE
#endif //if defined(_UNICODE)
#elif defined(UNDER_CE)
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
#else
int main()
#endif
{
COSVersion::OS_VERSION_INFO osvi;
memset(&osvi, 0, sizeof(osvi));
#ifdef _WIN32
TCHAR sText[512];
TCHAR sBuf[100];
#else
char sText[512];
char sBuf[100];
#endif
COSVersion os;
if (os.GetVersion(&osvi))
{
#ifndef UNDER_CE
_stprintf(sText, _T("Emulated OS: "));
switch (osvi.EmulatedPlatform)
{
case COSVersion::Dos:
{
_tcscat(sText, _T("DOS"));
break;
}
case COSVersion::Windows3x:
{
_tcscat(sText, _T("Windows"));
if (os.IsWin32sInstalled(&osvi))
_tcscat(sText, _T(" (Win32s)"));
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.IsEnterpriseWindowsServer2003R2(&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"));
break;
}
}
#ifndef UNDER_CE
switch (osvi.EmulatedProcessorType)
{
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::ALPHA64_PROCESSOR:
{
_tcscat(sText, _T(", (Alpha64 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.dwEmulatedMajorVersion);
_tcscat(sText, sBuf);
if (osvi.dwEmulatedMinorVersion % 10)
{
if (osvi.dwEmulatedMinorVersion > 9)
_stprintf(sBuf, _T("%02d"), osvi.dwEmulatedMinorVersion);
else
_stprintf(sBuf, _T("%01d"), osvi.dwEmulatedMinorVersion);
}
else
_stprintf(sBuf, _T("%01d"), osvi.dwEmulatedMinorVersion / 10);
_tcscat(sText, sBuf);
if (osvi.dwEmulatedBuildNumber)
{
_stprintf(sBuf, _T(" Build:%d"), osvi.dwEmulatedBuildNumber);
_tcscat(sText, sBuf);
}
if (osvi.wEmulatedServicePackMajor)
{
if (osvi.wEmulatedServicePackMinor)
{
//Handle the special case of NT 4 SP 6a which Dtwinver ver treats as SP 6.1
if (os.IsNTPreWin2k(&osvi) && (osvi.wEmulatedServicePackMajor == 6) && (osvi.wEmulatedServicePackMinor == 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.wEmulatedServicePackMajor == 1) && (osvi.wEmulatedServicePackMinor == 1))
_stprintf(sBuf, _T(" Service Pack: 1a"));
else
_stprintf(sBuf, _T(" Service Pack:%d.%d"), osvi.wEmulatedServicePackMajor, osvi.wEmulatedServicePackMinor);
}
else
_stprintf(sBuf, _T(" Service Pack:%d"), osvi.wEmulatedServicePackMajor);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -