diff --git a/Common/Platform.cpp b/Common/Platform.cpp index 777d5855..17ae0147 100644 --- a/Common/Platform.cpp +++ b/Common/Platform.cpp @@ -56,4 +56,110 @@ Version GetVersion() return s_Version; } +LPCWSTR GetPlatformName() +{ + OSVERSIONINFOEX osvi = { sizeof(OSVERSIONINFOEX) }; + if (GetVersionEx((OSVERSIONINFO*)&osvi)) + { + if (osvi.dwMajorVersion == 5) + { + if (osvi.dwMinorVersion == 2) + { + return L"Windows 2003"; + } + else if (osvi.dwMinorVersion == 1) + { + return L"Windows XP"; + } + } + else + { + if (osvi.dwMinorVersion == 3 && osvi.wProductType == VER_NT_WORKSTATION) + { + return L"Windows 8.1"; + } + else if (osvi.dwMinorVersion == 3 && osvi.wProductType != VER_NT_WORKSTATION) + { + return L"Windows Server 2012 R2"; + } + 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) + { + return L"Windows Server 2008 R2"; + } + else if (osvi.dwMinorVersion == 0 && osvi.wProductType == VER_NT_WORKSTATION) + { + return L"Windows Vista"; + } + else if (osvi.dwMinorVersion == 0 && osvi.wProductType != VER_NT_WORKSTATION) + { + return L"Windows Server 2008"; + } + } + } + + return L"Unknown"; +} + +/* +** Returns |true| if the OS architecture can be found (either 32-bit or 64-bit), +** or |false| if it cannot be determined. +** +** Note: IsWow64Process was introduced with Windows XP SP2. +*/ +bool GetPlatformBit(bool& is64Bit) +{ +#if _WIN64 + + is64Bit = true; + return true; + +#elif _WIN32 + + BOOL isWow64 = FALSE; + + LPFN_ISWOW64PROCESS fnIsWow64Process = + (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process"); + + if (fnIsWow64Process) + { + if (!fnIsWow64Process(GetCurrentProcess(), &isWow64)) + { + return false; + } + + if (isWow64) + { + is64Bit = true; + } + else + { + is64Bit = false; + } + + return true; + } + else + { + return false; + } + +#else + + return false; + +#endif +} + } // namespace Platform \ No newline at end of file diff --git a/Common/Platform.h b/Common/Platform.h index 325f8e91..0a01ec98 100644 --- a/Common/Platform.h +++ b/Common/Platform.h @@ -21,6 +21,8 @@ namespace Platform { +typedef BOOL(WINAPI * LPFN_ISWOW64PROCESS)(HANDLE hProcess, PBOOL Wow64Process); + enum Version { WinXP, @@ -30,6 +32,8 @@ enum Version }; Version GetVersion(); +LPCWSTR GetPlatformName(); +bool GetPlatformBit(bool& is64Bit); #define RM_PLATFORM_DECLARE_HELPERS(ver) \ inline bool IsAtMost ## ver() { return GetVersion() <= ver; } \ diff --git a/Library/DialogAbout.cpp b/Library/DialogAbout.cpp index ddf8cabb..2e25ce98 100644 --- a/Library/DialogAbout.cpp +++ b/Library/DialogAbout.cpp @@ -25,6 +25,7 @@ #include "resource.h" #include "DialogAbout.h" #include "../Version.h" +#include "../Common/Platform.h" WINDOWPLACEMENT DialogAbout::c_WindowPlacement = {0}; DialogAbout* DialogAbout::c_Dialog = nullptr; @@ -1206,17 +1207,20 @@ void DialogAbout::TabVersion::Create(HWND owner) CT_LINKLABEL(Id_LicenseLink, ID_STR_COPYRIGHTNOTICE, 28, 26, 300, 9, WS_VISIBLE, 0), - CT_LABEL(Id_PathLabel, 0, + CT_LABEL(Id_WinVerLabel, 0, 0, 43, 360, 9, WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0), - CT_LABEL(Id_IniFileLabel, 0, + CT_LABEL(Id_PathLabel, 0, 0, 56, 360, 9, WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0), - CT_LABEL(Id_SkinPathLabel, 0, + CT_LABEL(Id_IniFileLabel, 0, 0, 69, 360, 9, WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0), + CT_LABEL(Id_SkinPathLabel, 0, + 0, 82, 360, 9, + WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0), CT_BUTTON(Id_CopyButton, ID_STR_COPYTOCLIPBOARD, - 0, 85, buttonWidth + 25, 14, + 0, 98, buttonWidth + 25, 14, WS_VISIBLE | WS_TABSTOP, 0) }; @@ -1234,8 +1238,21 @@ void DialogAbout::TabVersion::Initialize() _snwprintf_s(tmpSz, _TRUNCATE, L"%s%s r%i %s (%s)", APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS, APPDATE); SetWindowText(item, tmpSz); + item = GetControl(Id_WinVerLabel); + std::wstring text = Platform::GetPlatformName(); + bool is64Bit = false; + if (Platform::GetPlatformBit(is64Bit)) + { + text.append(is64Bit ? L" (64-bit)" : L" (32-bit)"); + } + else + { + text.append(L" (???-bit)"); + } + SetWindowText(item, text.c_str()); + item = GetControl(Id_PathLabel); - std::wstring text = L"Path: " + GetRainmeter().GetPath(); + text = L"Path: " + GetRainmeter().GetPath(); SetWindowText(item, text.c_str()); item = GetControl(Id_IniFileLabel); diff --git a/Library/DialogAbout.h b/Library/DialogAbout.h index d6e31e2f..760b071b 100644 --- a/Library/DialogAbout.h +++ b/Library/DialogAbout.h @@ -143,6 +143,7 @@ private: Id_VersionLabel, Id_HomeLink, Id_LicenseLink, + Id_WinVerLabel, Id_PathLabel, Id_IniFileLabel, Id_SkinPathLabel, diff --git a/Plugins/PluginSysInfo/PluginSysInfo.vcxproj b/Plugins/PluginSysInfo/PluginSysInfo.vcxproj index 229e17ba..78809d57 100644 --- a/Plugins/PluginSysInfo/PluginSysInfo.vcxproj +++ b/Plugins/PluginSysInfo/PluginSysInfo.vcxproj @@ -30,6 +30,11 @@ + + + {19312085-aa51-4bd6-be92-4b6098cca539} + + diff --git a/Plugins/PluginSysInfo/SysInfo.cpp b/Plugins/PluginSysInfo/SysInfo.cpp index fa652023..46a699e8 100644 --- a/Plugins/PluginSysInfo/SysInfo.cpp +++ b/Plugins/PluginSysInfo/SysInfo.cpp @@ -23,6 +23,7 @@ #include #include "../API/RainmeterAPI.h" #include "../../Library/Export.h" +#include"../../Common/Platform.h" typedef struct { @@ -73,7 +74,6 @@ struct MeasureData MeasureData() : type(), data() {} }; -LPCWSTR GetPlatformName(); NLM_CONNECTIVITY GetNetworkConnectivity(); BOOL CALLBACK MyInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData); @@ -261,7 +261,7 @@ PLUGIN_EXPORT LPCWSTR GetString(void* data) return sBuffer; case MEASURE_OS_VERSION: - return GetPlatformName(); + return Platform::GetPlatformName(); case MEASURE_ADAPTER_DESCRIPTION: if (ERROR_SUCCESS == GetAdaptersInfo((IP_ADAPTER_INFO*)tmpBuffer, &tmpBufferLen)) @@ -468,62 +468,6 @@ PLUGIN_EXPORT void Finalize(void* data) delete measure; } -LPCWSTR GetPlatformName() -{ - OSVERSIONINFOEX osvi = {sizeof(OSVERSIONINFOEX)}; - if (GetVersionEx((OSVERSIONINFO*)&osvi)) - { - if (osvi.dwMajorVersion == 5) - { - if (osvi.dwMinorVersion == 2) - { - return L"Windows 2003"; - } - else if (osvi.dwMinorVersion == 1) - { - return L"Windows XP"; - } - } - else - { - if (osvi.dwMinorVersion == 3 && osvi.wProductType == VER_NT_WORKSTATION) - { - return L"Windows 8.1"; - } - else if (osvi.dwMinorVersion == 3 && osvi.wProductType != VER_NT_WORKSTATION) - { - return L"Windows Server 2012 R2"; - } - 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) - { - return L"Windows Server 2008 R2"; - } - else if (osvi.dwMinorVersion == 0 && osvi.wProductType == VER_NT_WORKSTATION) - { - return L"Windows Vista"; - } - else if (osvi.dwMinorVersion == 0 && osvi.wProductType != VER_NT_WORKSTATION) - { - return L"Windows Server 2008"; - } - } - } - - return L"Unknown"; -} - NLM_CONNECTIVITY GetNetworkConnectivity() { // This is initialized like this in case INetworkListManager is not available (i.e. on WinXP).