mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Tweaks
This commit is contained in:
parent
c71585a818
commit
7a1c0f6e78
@ -23,15 +23,15 @@ namespace Platform {
|
|||||||
|
|
||||||
LPCWSTR GetPlatformName()
|
LPCWSTR GetPlatformName()
|
||||||
{
|
{
|
||||||
bool isServer = IsWindowsServer();
|
const bool isServer = IsWindowsServer();
|
||||||
|
|
||||||
// Note: Place newer versions at the top.
|
// Note: Place newer versions at the top.
|
||||||
|
|
||||||
if (IsWindows8Point1OrGreater()) return isServer ? L"Windows Server 2012 R2" : L"Windows 8.1";
|
if (IsWindows8Point1OrGreater()) return isServer ? L"Windows Server 2012 R2" : L"Windows 8.1";
|
||||||
if (IsWindows8OrGreater()) return isServer ? L"Windows Server 2012" : L"Windows 8";
|
if (IsWindows8OrGreater()) return isServer ? L"Windows Server 2012" : L"Windows 8";
|
||||||
if (IsWindows7OrGreater()) return isServer ? L"Windows Server 2008 R2" : L"Windows 7";
|
if (IsWindows7OrGreater()) return isServer ? L"Windows Server 2008 R2" : L"Windows 7";
|
||||||
if (IsWindowsVistaOrGreater()) return isServer ? L"Windows Server 2008" : L"Windows Vista";
|
if (IsWindowsVistaOrGreater()) return isServer ? L"Windows Server 2008" : L"Windows Vista";
|
||||||
if (IsWindowsXPOrGreater()) return isServer ? L"Windows Server 2003" : L"Windows XP";
|
if (IsWindowsXPOrGreater()) return isServer ? L"Windows Server 2003" : L"Windows XP";
|
||||||
|
|
||||||
return L"Unknown";
|
return L"Unknown";
|
||||||
}
|
}
|
||||||
@ -39,38 +39,30 @@ LPCWSTR GetPlatformName()
|
|||||||
std::wstring GetPlatformFriendlyName()
|
std::wstring GetPlatformFriendlyName()
|
||||||
{
|
{
|
||||||
std::wstring name;
|
std::wstring name;
|
||||||
|
|
||||||
WCHAR* buffer = new WCHAR[MAX_LINE_LENGTH];
|
WCHAR buffer[256];
|
||||||
DWORD size = MAX_LINE_LENGTH;
|
DWORD size = _countof(buffer);
|
||||||
|
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (RegQueryValueEx(hKey, L"ProductName", nullptr, nullptr, (LPBYTE)buffer, (LPDWORD)&size) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hKey, L"ProductName", nullptr, nullptr, (LPBYTE)buffer, (LPDWORD)&size) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
bool is64Bit = false;
|
|
||||||
bool has64Bit = GetPlatformBit(is64Bit);
|
|
||||||
|
|
||||||
name += buffer;
|
name += buffer;
|
||||||
name += L' ';
|
name += L' ';
|
||||||
name += (has64Bit) ? (is64Bit) ? L" 64" : L" 32" : L" ???";
|
name += Is64BitWindows() ? L"64" : L"32";
|
||||||
name += L"-bit";
|
name += L"-bit";
|
||||||
|
|
||||||
size = MAX_LINE_LENGTH;
|
size = _countof(buffer);
|
||||||
if (RegQueryValueEx(hKey, L"CurrentBuildNumber", nullptr, nullptr, (LPBYTE)buffer, (LPDWORD)&size) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hKey, L"CurrentBuildNumber", nullptr, nullptr, (LPBYTE)buffer, (LPDWORD)&size) == ERROR_SUCCESS ||
|
||||||
{
|
RegQueryValueEx(hKey, L"CurrentBuild", nullptr, nullptr, (LPBYTE)buffer, (LPDWORD)&size) == ERROR_SUCCESS)
|
||||||
name += L" (build ";
|
|
||||||
name += buffer;
|
|
||||||
name += L')';
|
|
||||||
}
|
|
||||||
else if (RegQueryValueEx(hKey, L"CurrentBuild", nullptr, nullptr, (LPBYTE)buffer, (LPDWORD)&size) == ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
name += L" (build ";
|
name += L" (build ";
|
||||||
name += buffer;
|
name += buffer;
|
||||||
name += L')';
|
name += L')';
|
||||||
}
|
}
|
||||||
|
|
||||||
size = MAX_LINE_LENGTH;
|
size = _countof(buffer);
|
||||||
if (RegQueryValueEx(hKey, L"CSDVersion", nullptr, nullptr, (LPBYTE)buffer, (LPDWORD)&size) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hKey, L"CSDVersion", nullptr, nullptr, (LPBYTE)buffer, (LPDWORD)&size) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
name += L' ';
|
name += L' ';
|
||||||
@ -85,59 +77,27 @@ std::wstring GetPlatformFriendlyName()
|
|||||||
name = L"Windows version unknown";
|
name = L"Windows version unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] buffer;
|
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Returns |true| if the OS architecture can be found (either 32-bit or 64-bit),
|
** Returns |true| if running on 64-bit Windows.
|
||||||
** or |false| if it cannot be determined.
|
|
||||||
**
|
|
||||||
** Note: IsWow64Process was introduced with Windows XP SP2.
|
|
||||||
*/
|
*/
|
||||||
bool GetPlatformBit(bool& is64Bit)
|
bool Is64BitWindows()
|
||||||
{
|
{
|
||||||
#if _WIN64
|
#if _WIN64
|
||||||
|
|
||||||
is64Bit = true;
|
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
#elif _WIN32
|
typedef BOOL(WINAPI * IsWow64ProcessFunc)(HANDLE hProcess, PBOOL Wow64Process);
|
||||||
|
auto isWow64Process = (IsWow64ProcessFunc)GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process");
|
||||||
BOOL isWow64 = FALSE;
|
if (isWow64Process)
|
||||||
|
|
||||||
LPFN_ISWOW64PROCESS fnIsWow64Process =
|
|
||||||
(LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process");
|
|
||||||
|
|
||||||
if (fnIsWow64Process)
|
|
||||||
{
|
{
|
||||||
if (!fnIsWow64Process(GetCurrentProcess(), &isWow64))
|
BOOL isWow64 = FALSE;
|
||||||
{
|
return isWow64Process(GetCurrentProcess(), &isWow64) && isWow64;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isWow64)
|
|
||||||
{
|
|
||||||
is64Bit = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
is64Bit = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
@ -21,20 +21,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define MAX_LINE_LENGTH 4096
|
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
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();
|
||||||
std::wstring GetPlatformFriendlyName();
|
std::wstring GetPlatformFriendlyName();
|
||||||
bool GetPlatformBit(bool& is64Bit);
|
bool Is64BitWindows();
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user