This commit is contained in:
Brian Ferguson 2014-02-12 14:42:02 -07:00
parent eced3a6978
commit 67aeaf5392
21 changed files with 23 additions and 83 deletions

View File

@ -20,7 +20,6 @@
#include "Canvas.h" #include "Canvas.h"
#include "CanvasD2D.h" #include "CanvasD2D.h"
#include "CanvasGDIP.h" #include "CanvasGDIP.h"
#include "../Platform.h"
namespace Gfx { namespace Gfx {
@ -41,7 +40,7 @@ Canvas* Canvas::Create(Renderer renderer)
{ {
return new CanvasGDIP(); return new CanvasGDIP();
} }
else if (renderer == Renderer::D2D && Platform::IsAtLeastWin7()) else if (renderer == Renderer::D2D && IsWindows7OrGreater())
{ {
if (CanvasD2D::Initialize()) if (CanvasD2D::Initialize())
{ {

View File

@ -17,7 +17,6 @@
*/ */
#include "StdAfx.h" #include "StdAfx.h"
#include "../Platform.h"
#include "CanvasD2D.h" #include "CanvasD2D.h"
#include "TextFormatD2D.h" #include "TextFormatD2D.h"
#include "Util/DWriteFontCollectionLoader.h" #include "Util/DWriteFontCollectionLoader.h"
@ -69,7 +68,7 @@ bool CanvasD2D::Initialize()
++c_Instances; ++c_Instances;
if (c_Instances == 1) if (c_Instances == 1)
{ {
if (!Platform::IsAtLeastWin7()) return false; if (!IsWindows7OrGreater()) return false;
D2D1_FACTORY_OPTIONS fo = {}; D2D1_FACTORY_OPTIONS fo = {};
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -21,41 +21,6 @@
namespace Platform { 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() LPCWSTR GetPlatformName()
{ {
OSVERSIONINFOEX osvi = { sizeof(OSVERSIONINFOEX) }; OSVERSIONINFOEX osvi = { sizeof(OSVERSIONINFOEX) };

View File

@ -23,28 +23,9 @@ namespace Platform {
typedef BOOL(WINAPI * LPFN_ISWOW64PROCESS)(HANDLE hProcess, PBOOL Wow64Process); typedef BOOL(WINAPI * LPFN_ISWOW64PROCESS)(HANDLE hProcess, PBOOL Wow64Process);
enum Version
{
WinXP,
WinVista,
Win7,
Win8
};
Version GetVersion();
LPCWSTR GetPlatformName(); LPCWSTR GetPlatformName();
bool GetPlatformBit(bool& is64Bit); 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 } // namespace Platform
#endif #endif

View File

@ -36,6 +36,7 @@
#include <Uxtheme.h> #include <Uxtheme.h>
#include <wincodec.h> #include <wincodec.h>
#include <wrl/client.h> #include <wrl/client.h>
#include <VersionHelpers.h>
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>

View File

@ -22,7 +22,6 @@
#include "Resource.h" #include "Resource.h"
#include "Util.h" #include "Util.h"
#include "../Common/ControlTemplate.h" #include "../Common/ControlTemplate.h"
#include "../Common/Platform.h"
#define APPNAME L"Rainmeter" #define APPNAME L"Rainmeter"
@ -176,7 +175,7 @@ INT_PTR CDialogInstall::OnInitDialog(WPARAM wParam, LPARAM lParam)
item = GetControl(Id_InstallButton); item = GetControl(Id_InstallButton);
SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE); SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);
if (Platform::IsAtLeastWinVista() && !Util::IsProcessUserAdmin()) if (IsWindowsVistaOrGreater() && !Util::IsProcessUserAdmin())
{ {
Button_SetElevationRequiredState(item, TRUE); Button_SetElevationRequiredState(item, TRUE);
} }
@ -211,7 +210,7 @@ INT_PTR CDialogInstall::OnNotify(WPARAM wParam, LPARAM lParam)
void CDialogInstall::LaunchInstallProcess() void CDialogInstall::LaunchInstallProcess()
{ {
const bool isProcsesUserAdmin = Util::IsProcessUserAdmin(); const bool isProcsesUserAdmin = Util::IsProcessUserAdmin();
if (!isProcsesUserAdmin && (Platform::IsAtLeastWinVista() && !Util::CanProcessUserElevate())) if (!isProcsesUserAdmin && (IsWindowsVistaOrGreater() && !Util::CanProcessUserElevate()))
{ {
MessageBox( MessageBox(
m_Window, m_Window,

View File

@ -32,7 +32,6 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="..\Common\ControlTemplate.cpp" /> <ClCompile Include="..\Common\ControlTemplate.cpp" />
<ClCompile Include="..\Common\Dialog.cpp" /> <ClCompile Include="..\Common\Dialog.cpp" />
<ClCompile Include="..\Common\Platform.cpp" />
<ClCompile Include="Application.cpp" /> <ClCompile Include="Application.cpp" />
<ClCompile Include="DialogInstall.cpp" /> <ClCompile Include="DialogInstall.cpp" />
<ClCompile Include="Install.cpp" /> <ClCompile Include="Install.cpp" />

View File

@ -81,9 +81,6 @@
<ClCompile Include="DialogInstall.cpp"> <ClCompile Include="DialogInstall.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\Common\Platform.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="..\Common\ControlTemplate.cpp"> <ClCompile Include="..\Common\ControlTemplate.cpp">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClCompile> </ClCompile>

View File

@ -26,6 +26,7 @@
#include <shlobj.h> #include <shlobj.h>
#include <shlwapi.h> #include <shlwapi.h>
#include <wininet.h> #include <wininet.h>
#include <VersionHelpers.h>
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>

View File

@ -261,7 +261,7 @@ INT_PTR DialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam)
item = GetControl(Id_CloseButton); item = GetControl(Id_CloseButton);
SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE); SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);
if (Platform::IsAtLeastWinVista()) if (IsWindowsVistaOrGreater())
{ {
item = m_TabLog.GetControl(TabLog::Id_ItemsListView); item = m_TabLog.GetControl(TabLog::Id_ItemsListView);
SetWindowTheme(item, L"explorer", nullptr); SetWindowTheme(item, L"explorer", nullptr);
@ -683,7 +683,7 @@ void DialogAbout::TabSkins::Initialize()
LVGROUP lvg; LVGROUP lvg;
lvg.cbSize = sizeof(LVGROUP); lvg.cbSize = sizeof(LVGROUP);
lvg.mask = LVGF_HEADER | LVGF_GROUPID | LVGF_STATE; 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.iGroupId = 0;
lvg.pszHeader = GetString(ID_STR_MEASURES); lvg.pszHeader = GetString(ID_STR_MEASURES);
ListView_InsertGroup(item, 0, &lvg); ListView_InsertGroup(item, 0, &lvg);

View File

@ -263,7 +263,7 @@ INT_PTR DialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam)
item = m_TabSkins.GetControl(TabSkins::Id_FileLabel); item = m_TabSkins.GetControl(TabSkins::Id_FileLabel);
SendMessage(item, WM_SETFONT, (WPARAM)m_FontBold, 0); SendMessage(item, WM_SETFONT, (WPARAM)m_FontBold, 0);
if (Platform::IsAtLeastWinVista()) if (IsWindowsVistaOrGreater())
{ {
// Use arrows instead of plus/minus in the tree for Vista+ // Use arrows instead of plus/minus in the tree for Vista+
item = m_TabSkins.GetControl(TabSkins::Id_SkinsTreeView); item = m_TabSkins.GetControl(TabSkins::Id_SkinsTreeView);
@ -1948,7 +1948,7 @@ void DialogManage::TabSettings::Initialize()
bool iconEnabled = GetRainmeter().GetTrayWindow()->IsTrayIconEnabled(); bool iconEnabled = GetRainmeter().GetTrayWindow()->IsTrayIconEnabled();
Button_SetCheck(GetControl(Id_ShowTrayIconCheckBox), iconEnabled); Button_SetCheck(GetControl(Id_ShowTrayIconCheckBox), iconEnabled);
if (Platform::IsAtLeastWinVista()) if (IsWindowsVistaOrGreater())
{ {
Button_SetCheck(GetControl(Id_UseD2DCheckBox), GetRainmeter().GetUseD2D()); Button_SetCheck(GetControl(Id_UseD2DCheckBox), GetRainmeter().GetUseD2D());
} }

View File

@ -689,7 +689,7 @@ void MeasureNet::WriteStats(const WCHAR* iniFile, const std::wstring& statsDate)
*/ */
void MeasureNet::InitializeStatic() void MeasureNet::InitializeStatic()
{ {
if (Platform::IsAtLeastWinVista()) if (IsWindowsVistaOrGreater())
{ {
HMODULE IpHlpApiLibrary = GetModuleHandle(L"IpHlpApi.dll"); HMODULE IpHlpApiLibrary = GetModuleHandle(L"IpHlpApi.dll");
if (IpHlpApiLibrary) if (IpHlpApiLibrary)

View File

@ -142,7 +142,7 @@ MeterWindow::MeterWindow(const std::wstring& folderPath, const std::wstring& fil
m_FontCollection(), m_FontCollection(),
m_ToolTipHidden(false) m_ToolTipHidden(false)
{ {
if (!c_DwmInstance && Platform::IsAtLeastWinVista()) if (!c_DwmInstance && IsWindowsVistaOrGreater())
{ {
c_DwmInstance = System::RmLoadLibrary(L"dwmapi.dll"); c_DwmInstance = System::RmLoadLibrary(L"dwmapi.dll");
if (c_DwmInstance) if (c_DwmInstance)
@ -1040,7 +1040,7 @@ void MeterWindow::HideBlur()
*/ */
void MeterWindow::ResizeBlur(const std::wstring& arg, int mode) void MeterWindow::ResizeBlur(const std::wstring& arg, int mode)
{ {
if (Platform::IsAtLeastWinVista()) if (IsWindowsVistaOrGreater())
{ {
WCHAR* parseSz = _wcsdup(arg.c_str()); WCHAR* parseSz = _wcsdup(arg.c_str());
int type, x, y, w = 0, h = 0; 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_TransitionUpdate = m_Parser.ReadInt(L"Rainmeter", L"TransitionUpdate", INTERVAL_TRANSITION);
m_ToolTipHidden = m_Parser.ReadBool(L"Rainmeter", L"ToolTipHidden", false); m_ToolTipHidden = m_Parser.ReadBool(L"Rainmeter", L"ToolTipHidden", false);
if (Platform::IsAtLeastWinVista()) if (IsWindowsVistaOrGreater())
{ {
if (m_Parser.ReadBool(L"Rainmeter", L"Blur", false)) if (m_Parser.ReadBool(L"Rainmeter", L"Blur", false))
{ {
@ -2190,7 +2190,7 @@ bool MeterWindow::ReadSkin()
HANDLE find = FindFirstFileEx( HANDLE find = FindFirstFileEx(
resourcePath.c_str(), resourcePath.c_str(),
(Platform::IsAtLeastWin7()) ? FindExInfoBasic : FindExInfoStandard, (IsWindows7OrGreater()) ? FindExInfoBasic : FindExInfoStandard,
&fd, &fd,
FindExSearchNameMatch, FindExSearchNameMatch,
nullptr, nullptr,

View File

@ -1195,7 +1195,7 @@ void Rainmeter::ScanForLayouts()
hSearch = FindFirstFileEx( hSearch = FindFirstFileEx(
folders.c_str(), folders.c_str(),
(Platform::IsAtLeastWin7()) ? FindExInfoBasic : FindExInfoStandard, (IsWindows7OrGreater()) ? FindExInfoBasic : FindExInfoStandard,
&fileData, &fileData,
FindExSearchNameMatch, FindExSearchNameMatch,
nullptr, nullptr,

View File

@ -18,7 +18,6 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "../Common/PathUtil.h" #include "../Common/PathUtil.h"
#include "../Common/Platform.h"
#include "SkinRegistry.h" #include "SkinRegistry.h"
#include "resource.h" #include "resource.h"
@ -152,7 +151,7 @@ int SkinRegistry::PopulateRecursive(const std::wstring& path, std::wstring base,
hSearch = FindFirstFileEx( hSearch = FindFirstFileEx(
filter.c_str(), filter.c_str(),
(Platform::IsAtLeastWin7()) ? FindExInfoBasic : FindExInfoStandard, (IsWindows7OrGreater()) ? FindExInfoBasic : FindExInfoStandard,
&fileData, &fileData,
FindExSearchNameMatch, FindExSearchNameMatch,
nullptr, nullptr,

View File

@ -36,6 +36,7 @@
#include <shlobj.h> #include <shlobj.h>
#include <shlwapi.h> #include <shlwapi.h>
#include <Wininet.h> #include <Wininet.h>
#include <VersionHelpers.h>
// STL // STL
#include <map> #include <map>

View File

@ -1090,7 +1090,7 @@ void System::ResetWorkingDirectory()
void System::InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) void System::InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
{ {
typedef BOOL (WINAPI * FPINITCRITEX)(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount, DWORD Flags); 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; (FPINITCRITEX)GetProcAddress(GetModuleHandle(L"Kernel32"), "InitializeCriticalSectionEx") : nullptr;
if (InitializeCriticalSectionEx) if (InitializeCriticalSectionEx)
@ -1177,7 +1177,7 @@ void System::SetWallpaper(const std::wstring& wallpaper, const std::wstring& sty
{ {
wallStyle = L"2"; wallStyle = L"2";
} }
else if (Platform::IsAtLeastWin7()) else if (IsWindows7OrGreater())
{ {
if (_wcsicmp(option, L"FIT") == 0) if (_wcsicmp(option, L"FIT") == 0)
{ {

View File

@ -21,7 +21,6 @@
#include <windows.h> #include <windows.h>
#include <vector> #include <vector>
#include "../Common/Platform.h"
struct MonitorInfo struct MonitorInfo
{ {

View File

@ -307,7 +307,7 @@ void TrayWindow::ShowNotification(TRAY_NOTIFICATION id, const WCHAR* title, cons
wcsncpy_s(nid.szInfoTitle, title, _TRUNCATE); wcsncpy_s(nid.szInfoTitle, title, _TRUNCATE);
wcsncpy_s(nid.szInfo, text, _TRUNCATE); wcsncpy_s(nid.szInfo, text, _TRUNCATE);
if (Platform::IsAtLeastWin7()) if (IsWindows7OrGreater())
{ {
nid.dwInfoFlags |= NIIF_LARGE_ICON; nid.dwInfoFlags |= NIIF_LARGE_ICON;
nid.hBalloonIcon = GetIcon(IDI_RAINMETER, true); nid.hBalloonIcon = GetIcon(IDI_RAINMETER, true);

View File

@ -17,7 +17,6 @@
*/ */
#include "PluginFileView.h" #include "PluginFileView.h"
#include "../../Common/Platform.h"
#include "../../Common/StringUtil.h" #include "../../Common/StringUtil.h"
#define MAX_LINE_LENGTH 4096 #define MAX_LINE_LENGTH 4096
@ -82,7 +81,7 @@ PLUGIN_EXPORT void Initialize(void** data, void* rm)
{ {
std::wstring dir = RmReplaceVariables(rm, L"%WINDIR%"); std::wstring dir = RmReplaceVariables(rm, L"%WINDIR%");
dir.append(L"\\system32\\control.exe"); 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); g_SysProperties = StringUtil::Narrow(dir);
} }

View File

@ -27,6 +27,7 @@
#include <Shellapi.h> #include <Shellapi.h>
#include <Shlwapi.h> #include <Shlwapi.h>
#include <ShlObj.h> #include <ShlObj.h>
#include <VersionHelpers.h>
// STL // STL
#include <string> #include <string>