diff --git a/Common/Gfx/Canvas.cpp b/Common/Gfx/Canvas.cpp index 176a10ad..9b8a7270 100644 --- a/Common/Gfx/Canvas.cpp +++ b/Common/Gfx/Canvas.cpp @@ -20,7 +20,6 @@ #include "Canvas.h" #include "CanvasD2D.h" #include "CanvasGDIP.h" -#include "../Platform.h" namespace Gfx { @@ -41,7 +40,7 @@ Canvas* Canvas::Create(Renderer renderer) { return new CanvasGDIP(); } - else if (renderer == Renderer::D2D && Platform::IsAtLeastWin7()) + else if (renderer == Renderer::D2D && IsWindows7OrGreater()) { if (CanvasD2D::Initialize()) { diff --git a/Common/Gfx/CanvasD2D.cpp b/Common/Gfx/CanvasD2D.cpp index 5f41ff5f..55c79f1d 100644 --- a/Common/Gfx/CanvasD2D.cpp +++ b/Common/Gfx/CanvasD2D.cpp @@ -17,7 +17,6 @@ */ #include "StdAfx.h" -#include "../Platform.h" #include "CanvasD2D.h" #include "TextFormatD2D.h" #include "Util/DWriteFontCollectionLoader.h" @@ -69,7 +68,7 @@ bool CanvasD2D::Initialize() ++c_Instances; if (c_Instances == 1) { - if (!Platform::IsAtLeastWin7()) return false; + if (!IsWindows7OrGreater()) return false; D2D1_FACTORY_OPTIONS fo = {}; #ifdef _DEBUG diff --git a/Common/Platform.cpp b/Common/Platform.cpp index 17ae0147..2b829b1b 100644 --- a/Common/Platform.cpp +++ b/Common/Platform.cpp @@ -21,41 +21,6 @@ namespace Platform { -Version GetVersion() -{ - static Version s_Version = ([]() - { - OSVERSIONINFOEX osvi = {sizeof(OSVERSIONINFOEX)}; - if (GetVersionEx((OSVERSIONINFO*)&osvi)) - { - switch (osvi.dwMajorVersion) - { - case 5: - // Not checking for osvi.dwMinorVersion >= 1 because Rainmeter won't run on pre-XP. - return Version::WinXP; - - case 6: - switch (osvi.dwMinorVersion) - { - case 0: - return Version::WinVista; // Vista, Server 2008 - - case 1: - return Version::Win7; // 7, Server 2008R2 - - default: - return Version::Win8; // 8, Server 2012 - } - break; - } - } - - return Version::Win8; // newer OS - })(); - - return s_Version; -} - LPCWSTR GetPlatformName() { OSVERSIONINFOEX osvi = { sizeof(OSVERSIONINFOEX) }; diff --git a/Common/Platform.h b/Common/Platform.h index 0a01ec98..c329465d 100644 --- a/Common/Platform.h +++ b/Common/Platform.h @@ -23,28 +23,9 @@ namespace Platform { typedef BOOL(WINAPI * LPFN_ISWOW64PROCESS)(HANDLE hProcess, PBOOL Wow64Process); -enum Version -{ - WinXP, - WinVista, - Win7, - Win8 -}; - -Version GetVersion(); LPCWSTR GetPlatformName(); bool GetPlatformBit(bool& is64Bit); -#define RM_PLATFORM_DECLARE_HELPERS(ver) \ - inline bool IsAtMost ## ver() { return GetVersion() <= ver; } \ - inline bool Is ## ver() { return GetVersion() == ver; } \ - inline bool IsAtLeast ## ver() { return GetVersion() >= ver; } \ - -RM_PLATFORM_DECLARE_HELPERS(WinXP) -RM_PLATFORM_DECLARE_HELPERS(WinVista) -RM_PLATFORM_DECLARE_HELPERS(Win7) -RM_PLATFORM_DECLARE_HELPERS(Win8) - } // namespace Platform #endif diff --git a/Common/StdAfx.h b/Common/StdAfx.h index ab7af705..c574b6af 100644 --- a/Common/StdAfx.h +++ b/Common/StdAfx.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/Installer/DialogInstall.cpp b/Installer/DialogInstall.cpp index b86fb0c1..d71bf92b 100644 --- a/Installer/DialogInstall.cpp +++ b/Installer/DialogInstall.cpp @@ -22,7 +22,6 @@ #include "Resource.h" #include "Util.h" #include "../Common/ControlTemplate.h" -#include "../Common/Platform.h" #define APPNAME L"Rainmeter" @@ -176,7 +175,7 @@ INT_PTR CDialogInstall::OnInitDialog(WPARAM wParam, LPARAM lParam) item = GetControl(Id_InstallButton); SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE); - if (Platform::IsAtLeastWinVista() && !Util::IsProcessUserAdmin()) + if (IsWindowsVistaOrGreater() && !Util::IsProcessUserAdmin()) { Button_SetElevationRequiredState(item, TRUE); } @@ -211,7 +210,7 @@ INT_PTR CDialogInstall::OnNotify(WPARAM wParam, LPARAM lParam) void CDialogInstall::LaunchInstallProcess() { const bool isProcsesUserAdmin = Util::IsProcessUserAdmin(); - if (!isProcsesUserAdmin && (Platform::IsAtLeastWinVista() && !Util::CanProcessUserElevate())) + if (!isProcsesUserAdmin && (IsWindowsVistaOrGreater() && !Util::CanProcessUserElevate())) { MessageBox( m_Window, diff --git a/Installer/Installer.vcxproj b/Installer/Installer.vcxproj index f54e3d55..7df31532 100644 --- a/Installer/Installer.vcxproj +++ b/Installer/Installer.vcxproj @@ -32,7 +32,6 @@ - diff --git a/Installer/Installer.vcxproj.filters b/Installer/Installer.vcxproj.filters index adc2ff29..fb80296e 100644 --- a/Installer/Installer.vcxproj.filters +++ b/Installer/Installer.vcxproj.filters @@ -81,9 +81,6 @@ Source Files - - Common - Common diff --git a/Installer/StdAfx.h b/Installer/StdAfx.h index 0b582c4d..f0112ea7 100644 --- a/Installer/StdAfx.h +++ b/Installer/StdAfx.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include diff --git a/Library/DialogAbout.cpp b/Library/DialogAbout.cpp index 4419364a..e90d214b 100644 --- a/Library/DialogAbout.cpp +++ b/Library/DialogAbout.cpp @@ -261,7 +261,7 @@ INT_PTR DialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam) item = GetControl(Id_CloseButton); SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE); - if (Platform::IsAtLeastWinVista()) + if (IsWindowsVistaOrGreater()) { item = m_TabLog.GetControl(TabLog::Id_ItemsListView); SetWindowTheme(item, L"explorer", nullptr); @@ -683,7 +683,7 @@ void DialogAbout::TabSkins::Initialize() LVGROUP lvg; lvg.cbSize = sizeof(LVGROUP); lvg.mask = LVGF_HEADER | LVGF_GROUPID | LVGF_STATE; - lvg.state = (Platform::IsAtLeastWinVista()) ? LVGS_COLLAPSIBLE : LVGS_NORMAL; + lvg.state = (IsWindowsVistaOrGreater()) ? LVGS_COLLAPSIBLE : LVGS_NORMAL; lvg.iGroupId = 0; lvg.pszHeader = GetString(ID_STR_MEASURES); ListView_InsertGroup(item, 0, &lvg); diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index 3e37a68d..8f39ae16 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -263,7 +263,7 @@ INT_PTR DialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam) item = m_TabSkins.GetControl(TabSkins::Id_FileLabel); SendMessage(item, WM_SETFONT, (WPARAM)m_FontBold, 0); - if (Platform::IsAtLeastWinVista()) + if (IsWindowsVistaOrGreater()) { // Use arrows instead of plus/minus in the tree for Vista+ item = m_TabSkins.GetControl(TabSkins::Id_SkinsTreeView); @@ -1948,7 +1948,7 @@ void DialogManage::TabSettings::Initialize() bool iconEnabled = GetRainmeter().GetTrayWindow()->IsTrayIconEnabled(); Button_SetCheck(GetControl(Id_ShowTrayIconCheckBox), iconEnabled); - if (Platform::IsAtLeastWinVista()) + if (IsWindowsVistaOrGreater()) { Button_SetCheck(GetControl(Id_UseD2DCheckBox), GetRainmeter().GetUseD2D()); } diff --git a/Library/MeasureNet.cpp b/Library/MeasureNet.cpp index 6f85b6ed..2782fdbc 100644 --- a/Library/MeasureNet.cpp +++ b/Library/MeasureNet.cpp @@ -689,7 +689,7 @@ void MeasureNet::WriteStats(const WCHAR* iniFile, const std::wstring& statsDate) */ void MeasureNet::InitializeStatic() { - if (Platform::IsAtLeastWinVista()) + if (IsWindowsVistaOrGreater()) { HMODULE IpHlpApiLibrary = GetModuleHandle(L"IpHlpApi.dll"); if (IpHlpApiLibrary) diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 42746f4c..ef09d3cb 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -142,7 +142,7 @@ MeterWindow::MeterWindow(const std::wstring& folderPath, const std::wstring& fil m_FontCollection(), m_ToolTipHidden(false) { - if (!c_DwmInstance && Platform::IsAtLeastWinVista()) + if (!c_DwmInstance && IsWindowsVistaOrGreater()) { c_DwmInstance = System::RmLoadLibrary(L"dwmapi.dll"); if (c_DwmInstance) @@ -1040,7 +1040,7 @@ void MeterWindow::HideBlur() */ void MeterWindow::ResizeBlur(const std::wstring& arg, int mode) { - if (Platform::IsAtLeastWinVista()) + if (IsWindowsVistaOrGreater()) { WCHAR* parseSz = _wcsdup(arg.c_str()); int type, x, y, w = 0, h = 0; @@ -2149,7 +2149,7 @@ bool MeterWindow::ReadSkin() m_TransitionUpdate = m_Parser.ReadInt(L"Rainmeter", L"TransitionUpdate", INTERVAL_TRANSITION); m_ToolTipHidden = m_Parser.ReadBool(L"Rainmeter", L"ToolTipHidden", false); - if (Platform::IsAtLeastWinVista()) + if (IsWindowsVistaOrGreater()) { if (m_Parser.ReadBool(L"Rainmeter", L"Blur", false)) { @@ -2190,7 +2190,7 @@ bool MeterWindow::ReadSkin() HANDLE find = FindFirstFileEx( resourcePath.c_str(), - (Platform::IsAtLeastWin7()) ? FindExInfoBasic : FindExInfoStandard, + (IsWindows7OrGreater()) ? FindExInfoBasic : FindExInfoStandard, &fd, FindExSearchNameMatch, nullptr, diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 6f1b6809..10b708f9 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1195,7 +1195,7 @@ void Rainmeter::ScanForLayouts() hSearch = FindFirstFileEx( folders.c_str(), - (Platform::IsAtLeastWin7()) ? FindExInfoBasic : FindExInfoStandard, + (IsWindows7OrGreater()) ? FindExInfoBasic : FindExInfoStandard, &fileData, FindExSearchNameMatch, nullptr, diff --git a/Library/SkinRegistry.cpp b/Library/SkinRegistry.cpp index b401d50d..d97d4973 100644 --- a/Library/SkinRegistry.cpp +++ b/Library/SkinRegistry.cpp @@ -18,7 +18,6 @@ #include "StdAfx.h" #include "../Common/PathUtil.h" -#include "../Common/Platform.h" #include "SkinRegistry.h" #include "resource.h" @@ -152,7 +151,7 @@ int SkinRegistry::PopulateRecursive(const std::wstring& path, std::wstring base, hSearch = FindFirstFileEx( filter.c_str(), - (Platform::IsAtLeastWin7()) ? FindExInfoBasic : FindExInfoStandard, + (IsWindows7OrGreater()) ? FindExInfoBasic : FindExInfoStandard, &fileData, FindExSearchNameMatch, nullptr, diff --git a/Library/StdAfx.h b/Library/StdAfx.h index 84826088..eb117b76 100644 --- a/Library/StdAfx.h +++ b/Library/StdAfx.h @@ -36,6 +36,7 @@ #include #include #include +#include // STL #include diff --git a/Library/System.cpp b/Library/System.cpp index 4cf38374..3ce98988 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -1090,7 +1090,7 @@ void System::ResetWorkingDirectory() void System::InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { typedef BOOL (WINAPI * FPINITCRITEX)(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount, DWORD Flags); - static FPINITCRITEX InitializeCriticalSectionEx = Platform::IsAtLeastWinVista() ? + static FPINITCRITEX InitializeCriticalSectionEx = IsWindowsVistaOrGreater() ? (FPINITCRITEX)GetProcAddress(GetModuleHandle(L"Kernel32"), "InitializeCriticalSectionEx") : nullptr; if (InitializeCriticalSectionEx) @@ -1177,7 +1177,7 @@ void System::SetWallpaper(const std::wstring& wallpaper, const std::wstring& sty { wallStyle = L"2"; } - else if (Platform::IsAtLeastWin7()) + else if (IsWindows7OrGreater()) { if (_wcsicmp(option, L"FIT") == 0) { diff --git a/Library/System.h b/Library/System.h index 28bafb60..0c84bd61 100644 --- a/Library/System.h +++ b/Library/System.h @@ -21,7 +21,6 @@ #include #include -#include "../Common/Platform.h" struct MonitorInfo { diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index 7a4863ce..9ae6f355 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -307,7 +307,7 @@ void TrayWindow::ShowNotification(TRAY_NOTIFICATION id, const WCHAR* title, cons wcsncpy_s(nid.szInfoTitle, title, _TRUNCATE); wcsncpy_s(nid.szInfo, text, _TRUNCATE); - if (Platform::IsAtLeastWin7()) + if (IsWindows7OrGreater()) { nid.dwInfoFlags |= NIIF_LARGE_ICON; nid.hBalloonIcon = GetIcon(IDI_RAINMETER, true); diff --git a/Plugins/PluginFileView/PluginFileView.cpp b/Plugins/PluginFileView/PluginFileView.cpp index 2dbb7670..4ae003a9 100644 --- a/Plugins/PluginFileView/PluginFileView.cpp +++ b/Plugins/PluginFileView/PluginFileView.cpp @@ -17,7 +17,6 @@ */ #include "PluginFileView.h" -#include "../../Common/Platform.h" #include "../../Common/StringUtil.h" #define MAX_LINE_LENGTH 4096 @@ -82,7 +81,7 @@ PLUGIN_EXPORT void Initialize(void** data, void* rm) { std::wstring dir = RmReplaceVariables(rm, L"%WINDIR%"); dir.append(L"\\system32\\control.exe"); - dir.append(Platform::IsAtLeastWinVista() ? L" system" : L" sysdm.cpl"); + dir.append(IsWindowsVistaOrGreater() ? L" system" : L" sysdm.cpl"); g_SysProperties = StringUtil::Narrow(dir); } diff --git a/Plugins/PluginFileView/StdAfx.h b/Plugins/PluginFileView/StdAfx.h index e47de8d0..0aa2dafd 100644 --- a/Plugins/PluginFileView/StdAfx.h +++ b/Plugins/PluginFileView/StdAfx.h @@ -27,6 +27,7 @@ #include #include #include +#include // STL #include