mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Remove Platform version helpers and use <VersionHelpers.h> per http://msdn.microsoft.com/en-us/library/windows/desktop/dn424972%28v=vs.85%29.aspx
This commit is contained in:
parent
eced3a6978
commit
67aeaf5392
@ -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())
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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) };
|
||||
|
@ -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
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <Uxtheme.h>
|
||||
#include <wincodec.h>
|
||||
#include <wrl/client.h>
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
@ -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,
|
||||
|
@ -32,7 +32,6 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Common\ControlTemplate.cpp" />
|
||||
<ClCompile Include="..\Common\Dialog.cpp" />
|
||||
<ClCompile Include="..\Common\Platform.cpp" />
|
||||
<ClCompile Include="Application.cpp" />
|
||||
<ClCompile Include="DialogInstall.cpp" />
|
||||
<ClCompile Include="Install.cpp" />
|
||||
|
@ -81,9 +81,6 @@
|
||||
<ClCompile Include="DialogInstall.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\Platform.cpp">
|
||||
<Filter>Common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Common\ControlTemplate.cpp">
|
||||
<Filter>Common</Filter>
|
||||
</ClCompile>
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#include <wininet.h>
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -1195,7 +1195,7 @@ void Rainmeter::ScanForLayouts()
|
||||
|
||||
hSearch = FindFirstFileEx(
|
||||
folders.c_str(),
|
||||
(Platform::IsAtLeastWin7()) ? FindExInfoBasic : FindExInfoStandard,
|
||||
(IsWindows7OrGreater()) ? FindExInfoBasic : FindExInfoStandard,
|
||||
&fileData,
|
||||
FindExSearchNameMatch,
|
||||
nullptr,
|
||||
|
@ -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,
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#include <Wininet.h>
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
// STL
|
||||
#include <map>
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
#include "../Common/Platform.h"
|
||||
|
||||
struct MonitorInfo
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <Shellapi.h>
|
||||
#include <Shlwapi.h>
|
||||
#include <ShlObj.h>
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
// STL
|
||||
#include <string>
|
||||
|
Loading…
Reference in New Issue
Block a user