mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
About Dialog: Retrieve a more detailed OS name
This commit is contained in:
parent
67aeaf5392
commit
66d12ec92a
@ -18,63 +18,213 @@
|
|||||||
|
|
||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
LPCWSTR GetPlatformName()
|
LPCWSTR GetPlatformName(bool getExtendedInfo)
|
||||||
{
|
{
|
||||||
|
static WCHAR buffer[256];
|
||||||
|
wcscpy_s(buffer, L"");
|
||||||
|
|
||||||
|
bool isServer = IsWindowsServer();
|
||||||
|
|
||||||
OSVERSIONINFOEX osvi = { sizeof(OSVERSIONINFOEX) };
|
OSVERSIONINFOEX osvi = { sizeof(OSVERSIONINFOEX) };
|
||||||
if (GetVersionEx((OSVERSIONINFO*)&osvi))
|
if (GetVersionEx((OSVERSIONINFO*)&osvi))
|
||||||
{
|
{
|
||||||
if (osvi.dwMajorVersion == 5)
|
// Note: Place newer versions at the top. Service pack helper functions are commented out for
|
||||||
|
// backward compatibility with the SysInfo plugin.
|
||||||
|
|
||||||
|
if (IsWindows8Point1OrGreater())
|
||||||
{
|
{
|
||||||
if (osvi.dwMinorVersion == 2)
|
wcscat_s(buffer, isServer ? L"Windows Server 2012 R2" : L"Windows 8.1");
|
||||||
{
|
|
||||||
return L"Windows 2003";
|
|
||||||
}
|
}
|
||||||
else if (osvi.dwMinorVersion == 1)
|
else if (IsWindows8OrGreater())
|
||||||
{
|
{
|
||||||
return L"Windows XP";
|
wcscat_s(buffer, isServer ? L"Windows Server 2012" : L"Windows 8");
|
||||||
|
}
|
||||||
|
else if (IsWindows7OrGreater())
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, isServer ? L"Windows Server 2008 R2" : L"Windows 7");
|
||||||
|
}
|
||||||
|
else if (IsWindowsVistaOrGreater())
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, isServer ? L"Windows Server 2008" : L"Windows Vista");
|
||||||
|
}
|
||||||
|
else if (IsWindowsXPOrGreater())
|
||||||
|
{
|
||||||
|
if (GetSystemMetrics(SM_SERVERR2) != 0)
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, L"Windows Server 2003 R2");
|
||||||
|
}
|
||||||
|
else if (osvi.wSuiteMask & VER_SUITE_WH_SERVER)
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, L"Windows Home Server");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, isServer ? L"Windows Server 2003" : L"Windows XP");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (osvi.dwMinorVersion == 3 && osvi.wProductType == VER_NT_WORKSTATION)
|
wcscat_s(buffer, L"Unknown");
|
||||||
{
|
|
||||||
return L"Windows 8.1";
|
|
||||||
}
|
}
|
||||||
else if (osvi.dwMinorVersion == 3 && osvi.wProductType != VER_NT_WORKSTATION)
|
|
||||||
|
if (getExtendedInfo && _wcsicmp(buffer, L"Unknown") != 0)
|
||||||
{
|
{
|
||||||
return L"Windows Server 2012 R2";
|
if (IsWindowsVistaOrGreater())
|
||||||
|
{
|
||||||
|
PGETPRODUCTINFO pGetProductInfo = (PGETPRODUCTINFO)
|
||||||
|
GetProcAddress(GetModuleHandle(L"kernel32"), "GetProductInfo");
|
||||||
|
if (pGetProductInfo)
|
||||||
|
{
|
||||||
|
DWORD dwType;
|
||||||
|
if (pGetProductInfo(osvi.dwMajorVersion, osvi.dwMinorVersion,
|
||||||
|
osvi.wServicePackMajor, osvi.wServicePackMinor, &dwType))
|
||||||
|
{
|
||||||
|
// Only use most common versions.
|
||||||
|
// Full list at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724358%28v=vs.85%29.aspx
|
||||||
|
switch (dwType)
|
||||||
|
{
|
||||||
|
case PRODUCT_ULTIMATE:
|
||||||
|
case PRODUCT_ULTIMATE_N:
|
||||||
|
wcscat_s(buffer, L" Ultimate"); break;
|
||||||
|
|
||||||
|
case PRODUCT_PROFESSIONAL:
|
||||||
|
case PRODUCT_PROFESSIONAL_N:
|
||||||
|
wcscat_s(buffer, L" Professional"); break;
|
||||||
|
|
||||||
|
case PRODUCT_PROFESSIONAL_WMC:
|
||||||
|
wcscat_s(buffer, L" Professional Media Center"); break;
|
||||||
|
|
||||||
|
case PRODUCT_HOME_PREMIUM:
|
||||||
|
case PRODUCT_HOME_PREMIUM_N:
|
||||||
|
wcscat_s(buffer, L" Home Premium"); break;
|
||||||
|
|
||||||
|
case PRODUCT_HOME_BASIC:
|
||||||
|
case PRODUCT_HOME_BASIC_N:
|
||||||
|
wcscat_s(buffer, L" Home Basic"); break;
|
||||||
|
|
||||||
|
case PRODUCT_STARTER:
|
||||||
|
case PRODUCT_STARTER_N:
|
||||||
|
wcscat_s(buffer, L" Starter"); break;
|
||||||
|
|
||||||
|
case PRODUCT_ENTERPRISE:
|
||||||
|
case PRODUCT_ENTERPRISE_EVALUATION:
|
||||||
|
case PRODUCT_ENTERPRISE_N:
|
||||||
|
case PRODUCT_ENTERPRISE_N_EVALUATION:
|
||||||
|
wcscat_s(buffer, L" Enterprise"); break;
|
||||||
|
|
||||||
|
case PRODUCT_BUSINESS:
|
||||||
|
case PRODUCT_BUSINESS_N:
|
||||||
|
wcscat_s(buffer, L" Business"); break;
|
||||||
|
|
||||||
|
// Server Editions
|
||||||
|
case PRODUCT_CLUSTER_SERVER:
|
||||||
|
case PRODUCT_CLUSTER_SERVER_V:
|
||||||
|
wcscat_s(buffer, L" Cluster Edition"); break;
|
||||||
|
|
||||||
|
case PRODUCT_DATACENTER_SERVER:
|
||||||
|
case PRODUCT_DATACENTER_SERVER_V:
|
||||||
|
case PRODUCT_DATACENTER_SERVER_CORE:
|
||||||
|
case PRODUCT_DATACENTER_SERVER_CORE_V:
|
||||||
|
case PRODUCT_DATACENTER_EVALUATION_SERVER:
|
||||||
|
wcscat_s(buffer, L" Datacenter Edition"); break;
|
||||||
|
|
||||||
|
case PRODUCT_ENTERPRISE_SERVER:
|
||||||
|
case PRODUCT_ENTERPRISE_SERVER_V:
|
||||||
|
case PRODUCT_ENTERPRISE_SERVER_CORE:
|
||||||
|
case PRODUCT_ENTERPRISE_SERVER_CORE_V:
|
||||||
|
case PRODUCT_ENTERPRISE_SERVER_IA64:
|
||||||
|
wcscat_s(buffer, L" Enterprise Edition"); break;
|
||||||
|
|
||||||
|
case PRODUCT_SMALLBUSINESS_SERVER:
|
||||||
|
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
|
||||||
|
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE:
|
||||||
|
wcscat_s(buffer, L" Small Business Server"); break;
|
||||||
|
|
||||||
|
case PRODUCT_STANDARD_SERVER:
|
||||||
|
case PRODUCT_STANDARD_SERVER_V:
|
||||||
|
case PRODUCT_STANDARD_SERVER_CORE:
|
||||||
|
case PRODUCT_STANDARD_SERVER_CORE_V:
|
||||||
|
wcscat_s(buffer, L" Standard Edition"); break;
|
||||||
|
|
||||||
|
case PRODUCT_WEB_SERVER:
|
||||||
|
case PRODUCT_WEB_SERVER_CORE:
|
||||||
|
wcscat_s(buffer, L" Web Server"); break;
|
||||||
}
|
}
|
||||||
else if (osvi.dwMinorVersion == 2 && osvi.wProductType == VER_NT_WORKSTATION)
|
|
||||||
{
|
|
||||||
return L"Windows 8";
|
|
||||||
}
|
}
|
||||||
else if (osvi.dwMinorVersion == 2 && osvi.wProductType != VER_NT_WORKSTATION)
|
|
||||||
{
|
|
||||||
return L"Windows Server 2012";
|
|
||||||
}
|
}
|
||||||
else if (osvi.dwMinorVersion == 1 && osvi.wProductType == VER_NT_WORKSTATION)
|
|
||||||
{
|
|
||||||
return L"Windows 7";
|
|
||||||
}
|
}
|
||||||
else if (osvi.dwMinorVersion == 1 && osvi.wProductType != VER_NT_WORKSTATION)
|
else if (IsWindowsXPOrGreater())
|
||||||
{
|
{
|
||||||
return L"Windows Server 2008 R2";
|
if (isServer)
|
||||||
|
{
|
||||||
|
if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER)
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, L" Compute Cluster Edition");
|
||||||
}
|
}
|
||||||
else if (osvi.dwMinorVersion == 0 && osvi.wProductType == VER_NT_WORKSTATION)
|
else if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
|
||||||
{
|
{
|
||||||
return L"Windows Vista";
|
wcscat_s(buffer, L" Datacenter Edition");
|
||||||
}
|
}
|
||||||
else if (osvi.dwMinorVersion == 0 && osvi.wProductType != VER_NT_WORKSTATION)
|
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
|
||||||
{
|
{
|
||||||
return L"Windows Server 2008";
|
wcscat_s(buffer, L" Enterprise Edition");
|
||||||
|
}
|
||||||
|
else if (osvi.wSuiteMask & VER_SUITE_BLADE)
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, L" Web Edition");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, L" Standard Edition");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (osvi.wSuiteMask & VER_SUITE_PERSONAL)
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, L" Home Edition");
|
||||||
|
}
|
||||||
|
else if (GetSystemMetrics(SM_MEDIACENTER))
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, L" Media Center Edition");
|
||||||
|
}
|
||||||
|
else if (GetSystemMetrics(SM_STARTER))
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, L" Starter Edition");
|
||||||
|
}
|
||||||
|
else if (GetSystemMetrics(SM_TABLETPC))
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, L" Tablet PC Edition");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return L" Professional";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return L"Unknown";
|
// Build number and 32/64 bit
|
||||||
|
bool is64Bit = false;
|
||||||
|
bool has64Bit = Platform::GetPlatformBit(is64Bit);
|
||||||
|
_snwprintf_s(buffer, _TRUNCATE, L"%s %s-bit (build %d)",
|
||||||
|
buffer,
|
||||||
|
(has64Bit) ? (is64Bit) ? L"64" : L"32" : L"???",
|
||||||
|
osvi.dwBuildNumber);
|
||||||
|
|
||||||
|
// Service Pack
|
||||||
|
if (osvi.szCSDVersion)
|
||||||
|
{
|
||||||
|
wcscat_s(buffer, L", ");
|
||||||
|
wcscat_s(buffer, osvi.szCSDVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -22,8 +22,13 @@
|
|||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
typedef BOOL(WINAPI * LPFN_ISWOW64PROCESS)(HANDLE hProcess, PBOOL Wow64Process);
|
typedef BOOL(WINAPI * LPFN_ISWOW64PROCESS)(HANDLE hProcess, PBOOL Wow64Process);
|
||||||
|
typedef BOOL(WINAPI * PGETPRODUCTINFO)(DWORD dwOSMajorVersion,
|
||||||
|
DWORD dwOSMinorVersion,
|
||||||
|
DWORD dwSpMajorVersion,
|
||||||
|
DWORD dwSpMinorVersion,
|
||||||
|
PDWORD pdwReturnedProductType);
|
||||||
|
|
||||||
LPCWSTR GetPlatformName();
|
LPCWSTR GetPlatformName(bool getExtendedInfo = false);
|
||||||
bool GetPlatformBit(bool& is64Bit);
|
bool GetPlatformBit(bool& is64Bit);
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
@ -1239,20 +1239,10 @@ void DialogAbout::TabVersion::Initialize()
|
|||||||
SetWindowText(item, tmpSz);
|
SetWindowText(item, tmpSz);
|
||||||
|
|
||||||
item = GetControl(Id_WinVerLabel);
|
item = GetControl(Id_WinVerLabel);
|
||||||
std::wstring text = Platform::GetPlatformName();
|
SetWindowText(item, Platform::GetPlatformName(true));
|
||||||
bool is64Bit = false;
|
|
||||||
if (Platform::GetPlatformBit(is64Bit))
|
|
||||||
{
|
|
||||||
text += (is64Bit) ? L" (64-bit)" : L" (32-bit)";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
text += L" (???-bit)";
|
|
||||||
}
|
|
||||||
SetWindowText(item, text.c_str());
|
|
||||||
|
|
||||||
item = GetControl(Id_PathLabel);
|
item = GetControl(Id_PathLabel);
|
||||||
text = L"Path: " + GetRainmeter().GetPath();
|
std::wstring text = L"Path: " + GetRainmeter().GetPath();
|
||||||
SetWindowText(item, text.c_str());
|
SetWindowText(item, text.c_str());
|
||||||
|
|
||||||
item = GetControl(Id_IniFileLabel);
|
item = GetControl(Id_IniFileLabel);
|
||||||
@ -1299,16 +1289,7 @@ INT_PTR DialogAbout::TabVersion::OnCommand(WPARAM wParam, LPARAM lParam)
|
|||||||
int len = _snwprintf_s(tmpSz, _TRUNCATE, L"%s%s r%i %s (%s)", APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS, APPDATE);
|
int len = _snwprintf_s(tmpSz, _TRUNCATE, L"%s%s r%i %s (%s)", APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS, APPDATE);
|
||||||
std::wstring text(tmpSz, len);
|
std::wstring text(tmpSz, len);
|
||||||
text += L'\n';
|
text += L'\n';
|
||||||
text += Platform::GetPlatformName();
|
text += Platform::GetPlatformName(true);
|
||||||
bool is64Bit = false;
|
|
||||||
if (Platform::GetPlatformBit(is64Bit))
|
|
||||||
{
|
|
||||||
text += (is64Bit) ? L" (64-bit)" : L" (32-bit)";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
text += L" (???-bit)";
|
|
||||||
}
|
|
||||||
text += L"\nPath: ";
|
text += L"\nPath: ";
|
||||||
text += GetRainmeter().GetPath();
|
text += GetRainmeter().GetPath();
|
||||||
text += L"\nIniFile: ";
|
text += L"\nIniFile: ";
|
||||||
|
Loading…
Reference in New Issue
Block a user