📄 dtwinver.cpp
字号:
{
lpVersionInformation->OSType = DomainController;
break;
}
case VER_NT_SERVER:
{
lpVersionInformation->OSType = Server;
break;
}
default:
{
break;
}
}
//Determine if we are using the "Standard" version of the server
if ((lpVersionInformation->OSType != Workstation) && ((osviex.wSuiteMask & COSVERSION_SUITE_ENTERPRISE) == 0) &&
((osviex.wSuiteMask & COSVERSION_SUITE_DATACENTER) == 0) && ((osviex.wSuiteMask & COSVERSION_SUITE_WEBEDITION) == 0))
lpVersionInformation->dwSuiteMask2 |= COSVERSION_SUITE2_STANDARD;
//Determine the Domain Controller Type
GetNTOSTypeFromRegistry(lpVersionInformation, TRUE);
//Get the media center details
GetMediaCenterDetails(lpVersionInformation);
//Get the tablet PC details
GetTabletPCDetails(lpVersionInformation);
//Get the Starter Edition details
GetStarterEditionDetails(lpVersionInformation);
//Get the R2 details
GetR2Details(lpVersionInformation);
//Get the Vista SKU details
GetProductInfo(lpVersionInformation);
//Explicitly map the win32 dwPlatformId to our own values
switch (osviex.dwPlatformId)
{
case VER_PLATFORM_WIN32_WINDOWS:
{
lpVersionInformation->EmulatedPlatform = Windows9x;
break;
}
case VER_PLATFORM_WIN32_NT:
{
lpVersionInformation->EmulatedPlatform = WindowsNT;
break;
}
case VER_PLATFORM_WIN32_CE:
{
lpVersionInformation->EmulatedPlatform = WindowsCE;
break;
}
default:
{
break;
}
}
lpVersionInformation->dwUnderlyingMajorVersion = lpVersionInformation->dwEmulatedMajorVersion;
lpVersionInformation->dwUnderlyingMinorVersion = lpVersionInformation->dwEmulatedMinorVersion;
lpVersionInformation->dwUnderlyingBuildNumber = lpVersionInformation->dwEmulatedBuildNumber;
lpVersionInformation->UnderlyingPlatform = lpVersionInformation->EmulatedPlatform;
_tcscpy(lpVersionInformation->szUnderlyingCSDVersion, lpVersionInformation->szEmulatedCSDVersion);
lpVersionInformation->wUnderlyingServicePackMajor = lpVersionInformation->wEmulatedServicePackMajor;
lpVersionInformation->wUnderlyingServicePackMinor = lpVersionInformation->wEmulatedServicePackMinor;
#ifndef UNDER_CE
//Determine if it is NT SP6a Vs SP6
GetNTSP6aDetailsFromRegistry(lpVersionInformation, TRUE);
//Determine if it is XP SP1a Vs SP1
GetXPSP1aDetailsFromRegistry(lpVersionInformation, TRUE);
//Determine the HAL details
GetNTHALDetailsFromRegistry(lpVersionInformation);
#endif
}
else
{
lpVersionInformation->dwEmulatedMajorVersion = osvi.dwMajorVersion;
lpVersionInformation->dwEmulatedMinorVersion = osvi.dwMinorVersion;
lpVersionInformation->dwEmulatedBuildNumber = LOWORD(osvi.dwBuildNumber); //ignore HIWORD
_tcscpy(lpVersionInformation->szEmulatedCSDVersion, osvi.szCSDVersion);
//Explicitely map the win32 dwPlatformId to our own values
//Also work out the various service packs which are installed
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
lpVersionInformation->EmulatedPlatform = Windows9x;
lpVersionInformation->OSType = Workstation;
}
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
lpVersionInformation->EmulatedPlatform = WindowsNT;
//Determine the NT Service pack
lpVersionInformation->wEmulatedServicePackMajor = GetNTServicePackFromCSDString(osvi.szCSDVersion);
lpVersionInformation->wUnderlyingServicePackMajor = lpVersionInformation->wEmulatedServicePackMajor;
//Determine the OS Type
GetNTOSTypeFromRegistry(lpVersionInformation, FALSE);
//Get the Product Suites installed
GetProductSuiteDetailsFromRegistry(lpVersionInformation);
GetTerminalServicesRemoteAdminModeDetailsFromRegistry(lpVersionInformation);
}
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_CE)
{
lpVersionInformation->EmulatedPlatform = WindowsCE;
//Always set the OSType to Workstation on CE. The variable itself does not make
//much sense on CE, but we do not conditionally compile it out on CE as then we
//would have to put in loadsa ifdefs UNDER_CE in the COSVersion::Is... methods
lpVersionInformation->OSType = Workstation;
}
if (osvi.dwPlatformId == VER_PLATFORM_WIN32s) //32 bit app running on Windows 3.x
{
lpVersionInformation->EmulatedPlatform = Windows9x;
lpVersionInformation->dwUnderlyingMajorVersion = 3;
lpVersionInformation->dwUnderlyingMinorVersion = 10;
lpVersionInformation->dwUnderlyingBuildNumber = 0;
lpVersionInformation->UnderlyingPlatform = Windows3x;
_tcscpy(lpVersionInformation->szUnderlyingCSDVersion, _T(""));
}
else
{
lpVersionInformation->dwUnderlyingMajorVersion = lpVersionInformation->dwEmulatedMajorVersion;
lpVersionInformation->dwUnderlyingMinorVersion = lpVersionInformation->dwEmulatedMinorVersion;
lpVersionInformation->dwUnderlyingBuildNumber = lpVersionInformation->dwEmulatedBuildNumber;
lpVersionInformation->UnderlyingPlatform = lpVersionInformation->EmulatedPlatform;
_tcscpy(lpVersionInformation->szUnderlyingCSDVersion, lpVersionInformation->szEmulatedCSDVersion);
}
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
//Determine if it is NT SP6a Vs SP6
GetNTSP6aDetailsFromRegistry(lpVersionInformation, TRUE);
//Determine if it is XP SP1a Vs SP1
GetXPSP1aDetailsFromRegistry(lpVersionInformation, TRUE);
//Determine the HAL details
GetNTHALDetailsFromRegistry(lpVersionInformation);
}
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
//Form the Windows 9x Service pack info
if (IsWindows95SP1(lpVersionInformation))
{
lpVersionInformation->wEmulatedServicePackMajor = 1;
lpVersionInformation->wUnderlyingServicePackMajor = 1;
}
else if (IsWindows95B(lpVersionInformation))
{
lpVersionInformation->wEmulatedServicePackMajor = 2;
lpVersionInformation->wUnderlyingServicePackMajor = 2;
}
else if (IsWindows95C(lpVersionInformation))
{
lpVersionInformation->wEmulatedServicePackMajor = 2;
lpVersionInformation->wEmulatedServicePackMinor = 5;
lpVersionInformation->wUnderlyingServicePackMajor = 2;
lpVersionInformation->wUnderlyingServicePackMinor = 5;
}
else if (IsWindows98SP1(lpVersionInformation))
{
lpVersionInformation->wEmulatedServicePackMajor = 1;
lpVersionInformation->wUnderlyingServicePackMajor = 1;
}
}
}
}
else
{
//Since GetVersionEx is not available we need to fall back on plain
//old GetVersion. Because GetVersionEx is available on all but v3.1 of NT
//we can fill in some of the parameters ourselves.
DWORD dwVersion = ::GetVersion();
lpVersionInformation->dwEmulatedMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
lpVersionInformation->dwEmulatedMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
lpVersionInformation->dwEmulatedBuildNumber = 0;
lpVersionInformation->EmulatedPlatform = WindowsNT;
lpVersionInformation->dwUnderlyingMajorVersion = lpVersionInformation->dwEmulatedMajorVersion;
lpVersionInformation->dwUnderlyingMinorVersion = lpVersionInformation->dwEmulatedMinorVersion;
lpVersionInformation->dwUnderlyingBuildNumber = lpVersionInformation->dwEmulatedBuildNumber;
lpVersionInformation->UnderlyingPlatform = lpVersionInformation->EmulatedPlatform;
_tcscpy(lpVersionInformation->szUnderlyingCSDVersion, lpVersionInformation->szEmulatedCSDVersion);
//Need to determine the NT Service pack by querying the registry directory.
lpVersionInformation->wEmulatedServicePackMajor = GetNTServicePackFromRegistry();
lpVersionInformation->wUnderlyingServicePackMajor = lpVersionInformation->wEmulatedServicePackMajor;
}
#ifndef UNDER_CE
//Get the processor details
if (hKernel32)
{
SYSTEM_INFO EmulatedSI;
SYSTEM_INFO UnderlyingSI;
lpfnGetNativeSystemInfo pGetNativeSystemInfo = (lpfnGetNativeSystemInfo) GetProcAddress(hKernel32, "GetNativeSystemInfo");
if (pGetNativeSystemInfo)
{
pGetNativeSystemInfo(&UnderlyingSI);
GetSystemInfo(&EmulatedSI);
}
else
{
GetSystemInfo(&UnderlyingSI);
CopyMemory(&EmulatedSI, &UnderlyingSI, sizeof(SYSTEM_INFO));
}
//Map from the SYTEM_INFO wProcessorArchitecture defines to our equivalents
switch (UnderlyingSI.wProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_INTEL: //deliberate fallthrough
case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
{
lpVersionInformation->UnderlyingProcessorType = IA32_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_MSIL:
{
lpVersionInformation->UnderlyingProcessorType = MSIL_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_MIPS:
{
lpVersionInformation->UnderlyingProcessorType = MIPS_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_ARM:
{
lpVersionInformation->UnderlyingProcessorType = ARM_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_SHX:
{
lpVersionInformation->UnderlyingProcessorType = SHX_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_ALPHA:
{
lpVersionInformation->UnderlyingProcessorType = ALPHA_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_ALPHA64:
{
lpVersionInformation->UnderlyingProcessorType = ALPHA64_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_PPC:
{
lpVersionInformation->UnderlyingProcessorType = PPC_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_IA64:
{
lpVersionInformation->UnderlyingProcessorType = IA64_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_AMD64:
{
lpVersionInformation->UnderlyingProcessorType = AMD64_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_UNKNOWN: //Deliberate fallthrough
default:
{
lpVersionInformation->UnderlyingProcessorType = UNKNOWN_PROCESSOR;
break;
}
}
switch (EmulatedSI.wProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_INTEL: //deliberate fallthrough
case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
{
lpVersionInformation->EmulatedProcessorType = IA32_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_MSIL:
{
lpVersionInformation->EmulatedProcessorType = MSIL_PROCESSOR;
break;
}
case PROCESSOR_ARCHITECTURE_MIPS:
{
lpVersionInformation->EmulatedProcessorType = MIPS_PROCESSOR;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -