mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Use decltype instead of typedefs for function pointers
This commit is contained in:
parent
27af737a3a
commit
3190fc267f
@ -89,8 +89,7 @@ bool Is64BitWindows()
|
||||
return true;
|
||||
#endif
|
||||
|
||||
typedef BOOL(WINAPI * IsWow64ProcessFunc)(HANDLE hProcess, PBOOL Wow64Process);
|
||||
auto isWow64Process = (IsWow64ProcessFunc)GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process");
|
||||
auto isWow64Process = (decltype(IsWow64Process)*)GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process");
|
||||
if (isWow64Process)
|
||||
{
|
||||
BOOL isWow64 = FALSE;
|
||||
|
@ -58,14 +58,12 @@ std::wstring GetFormattedString(UINT id, ...)
|
||||
|
||||
HICON GetIcon(UINT id, bool large)
|
||||
{
|
||||
typedef HRESULT (WINAPI * FPLOADICONMETRIC)(HINSTANCE hinst, PCWSTR pszName, int lims, HICON* phico);
|
||||
|
||||
HINSTANCE hExe = GetModuleHandle(nullptr);
|
||||
HINSTANCE hComctl = GetModuleHandle(L"Comctl32");
|
||||
if (hComctl)
|
||||
{
|
||||
// Try LoadIconMetric for better quality with high DPI
|
||||
FPLOADICONMETRIC loadIconMetric = (FPLOADICONMETRIC)GetProcAddress(hComctl, "LoadIconMetric");
|
||||
auto loadIconMetric = (decltype(LoadIconMetric)*)GetProcAddress(hComctl, "LoadIconMetric");
|
||||
if (loadIconMetric)
|
||||
{
|
||||
HICON icon;
|
||||
|
@ -26,8 +26,8 @@ UINT MeasureNet::c_NumOfTables = 0;
|
||||
std::vector<ULONG64> MeasureNet::c_StatValues;
|
||||
std::vector<ULONG64> MeasureNet::c_OldStatValues;
|
||||
|
||||
FPGETIFTABLE2 MeasureNet::c_GetIfTable2 = nullptr;
|
||||
FPFREEMIBTABLE MeasureNet::c_FreeMibTable = nullptr;
|
||||
decltype(GetIfTable2)* MeasureNet::c_GetIfTable2 = nullptr;
|
||||
decltype(FreeMibTable)* MeasureNet::c_FreeMibTable = nullptr;
|
||||
|
||||
/*
|
||||
** The constructor. This is the base class for the net-meters.
|
||||
@ -694,8 +694,8 @@ void MeasureNet::InitializeStatic()
|
||||
HMODULE IpHlpApiLibrary = GetModuleHandle(L"IpHlpApi.dll");
|
||||
if (IpHlpApiLibrary)
|
||||
{
|
||||
c_GetIfTable2 = (FPGETIFTABLE2)GetProcAddress(IpHlpApiLibrary, "GetIfTable2");
|
||||
c_FreeMibTable = (FPFREEMIBTABLE)GetProcAddress(IpHlpApiLibrary, "FreeMibTable");
|
||||
c_GetIfTable2 = (decltype(c_GetIfTable2))GetProcAddress(IpHlpApiLibrary, "GetIfTable2");
|
||||
c_FreeMibTable = (decltype(c_FreeMibTable))GetProcAddress(IpHlpApiLibrary, "FreeMibTable");
|
||||
}
|
||||
|
||||
if (!c_GetIfTable2 || !c_FreeMibTable)
|
||||
|
@ -24,9 +24,6 @@
|
||||
#include <Iphlpapi.h>
|
||||
#include "Measure.h"
|
||||
|
||||
typedef NETIO_STATUS (NETIOAPI_API_ * FPGETIFTABLE2)(PMIB_IF_TABLE2* Table);
|
||||
typedef VOID (NETIOAPI_API_ * FPFREEMIBTABLE)(PVOID Memory);
|
||||
|
||||
class MeasureNet : public Measure
|
||||
{
|
||||
public:
|
||||
@ -75,8 +72,8 @@ private:
|
||||
static BYTE* c_Table;
|
||||
static UINT c_NumOfTables;
|
||||
|
||||
static FPGETIFTABLE2 c_GetIfTable2;
|
||||
static FPFREEMIBTABLE c_FreeMibTable;
|
||||
static decltype(GetIfTable2)* c_GetIfTable2;
|
||||
static decltype(FreeMibTable)* c_FreeMibTable;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -64,10 +64,10 @@ enum INTERVAL
|
||||
int MeterWindow::c_InstanceCount = 0;
|
||||
|
||||
HINSTANCE MeterWindow::c_DwmInstance = nullptr;
|
||||
FPDWMENABLEBLURBEHINDWINDOW MeterWindow::c_DwmEnableBlurBehindWindow = nullptr;
|
||||
FPDWMGETCOLORIZATIONCOLOR MeterWindow::c_DwmGetColorizationColor = nullptr;
|
||||
FPDWMSETWINDOWATTRIBUTE MeterWindow::c_DwmSetWindowAttribute = nullptr;
|
||||
FPDWMISCOMPOSITIONENABLED MeterWindow::c_DwmIsCompositionEnabled = nullptr;
|
||||
decltype(DwmEnableBlurBehindWindow)* MeterWindow::c_DwmEnableBlurBehindWindow = nullptr;
|
||||
decltype(DwmGetColorizationColor)* MeterWindow::c_DwmGetColorizationColor = nullptr;
|
||||
decltype(DwmSetWindowAttribute)* MeterWindow::c_DwmSetWindowAttribute = nullptr;
|
||||
decltype(DwmIsCompositionEnabled)* MeterWindow::c_DwmIsCompositionEnabled = nullptr;
|
||||
|
||||
/*
|
||||
** Constructor
|
||||
@ -142,16 +142,17 @@ MeterWindow::MeterWindow(const std::wstring& folderPath, const std::wstring& fil
|
||||
m_FontCollection(),
|
||||
m_ToolTipHidden(false)
|
||||
{
|
||||
if (!c_DwmInstance && IsWindowsVistaOrGreater())
|
||||
if (!c_DwmInstance && IsWindowsVistaOrGreater() &&
|
||||
(c_DwmInstance = System::RmLoadLibrary(L"dwmapi.dll")) != nullptr)
|
||||
{
|
||||
c_DwmInstance = System::RmLoadLibrary(L"dwmapi.dll");
|
||||
if (c_DwmInstance)
|
||||
{
|
||||
c_DwmEnableBlurBehindWindow = (FPDWMENABLEBLURBEHINDWINDOW)GetProcAddress(c_DwmInstance, "DwmEnableBlurBehindWindow");
|
||||
c_DwmGetColorizationColor = (FPDWMGETCOLORIZATIONCOLOR)GetProcAddress(c_DwmInstance, "DwmGetColorizationColor");
|
||||
c_DwmSetWindowAttribute = (FPDWMSETWINDOWATTRIBUTE)GetProcAddress(c_DwmInstance, "DwmSetWindowAttribute");
|
||||
c_DwmIsCompositionEnabled = (FPDWMISCOMPOSITIONENABLED)GetProcAddress(c_DwmInstance, "DwmIsCompositionEnabled");
|
||||
}
|
||||
c_DwmEnableBlurBehindWindow =
|
||||
(decltype(c_DwmEnableBlurBehindWindow))GetProcAddress(c_DwmInstance, "DwmEnableBlurBehindWindow");
|
||||
c_DwmGetColorizationColor =
|
||||
(decltype(c_DwmGetColorizationColor))GetProcAddress(c_DwmInstance, "DwmGetColorizationColor");
|
||||
c_DwmSetWindowAttribute =
|
||||
(decltype(c_DwmSetWindowAttribute))GetProcAddress(c_DwmInstance, "DwmSetWindowAttribute");
|
||||
c_DwmIsCompositionEnabled =
|
||||
(decltype(c_DwmIsCompositionEnabled))GetProcAddress(c_DwmInstance, "DwmIsCompositionEnabled");
|
||||
}
|
||||
|
||||
if (c_InstanceCount == 0)
|
||||
|
@ -40,11 +40,6 @@
|
||||
|
||||
#define RI_MOUSE_HORIZONTAL_WHEEL 0x0800
|
||||
|
||||
typedef HRESULT (WINAPI * FPDWMENABLEBLURBEHINDWINDOW)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind);
|
||||
typedef HRESULT (WINAPI * FPDWMGETCOLORIZATIONCOLOR)(DWORD* pcrColorization, BOOL* pfOpaqueBlend);
|
||||
typedef HRESULT (WINAPI * FPDWMSETWINDOWATTRIBUTE)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
|
||||
typedef HRESULT (WINAPI * FPDWMISCOMPOSITIONENABLED)(BOOL* pfEnabled);
|
||||
|
||||
enum BUTTONPROC
|
||||
{
|
||||
BUTTONPROC_DOWN,
|
||||
@ -433,10 +428,10 @@ private:
|
||||
|
||||
static HINSTANCE c_DwmInstance;
|
||||
|
||||
static FPDWMENABLEBLURBEHINDWINDOW c_DwmEnableBlurBehindWindow;
|
||||
static FPDWMGETCOLORIZATIONCOLOR c_DwmGetColorizationColor;
|
||||
static FPDWMSETWINDOWATTRIBUTE c_DwmSetWindowAttribute;
|
||||
static FPDWMISCOMPOSITIONENABLED c_DwmIsCompositionEnabled;
|
||||
static decltype(DwmEnableBlurBehindWindow)* c_DwmEnableBlurBehindWindow;
|
||||
static decltype(DwmGetColorizationColor)* c_DwmGetColorizationColor;
|
||||
static decltype(DwmSetWindowAttribute)* c_DwmSetWindowAttribute;
|
||||
static decltype(DwmIsCompositionEnabled)* c_DwmIsCompositionEnabled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1000,12 +1000,12 @@ LRESULT CALLBACK System::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
*/
|
||||
ULONGLONG System::GetTickCount64()
|
||||
{
|
||||
typedef ULONGLONG (WINAPI * FPGETTICKCOUNT64)();
|
||||
static FPGETTICKCOUNT64 c_GetTickCount64 = (FPGETTICKCOUNT64)GetProcAddress(GetModuleHandle(L"kernel32"), "GetTickCount64");
|
||||
static auto s_GetTickCount64 =
|
||||
(decltype(GetTickCount64)*)GetProcAddress(GetModuleHandle(L"kernel32"), "GetTickCount64");
|
||||
|
||||
if (c_GetTickCount64)
|
||||
if (s_GetTickCount64)
|
||||
{
|
||||
return c_GetTickCount64();
|
||||
return s_GetTickCount64();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1089,19 +1089,16 @@ void System::ResetWorkingDirectory()
|
||||
*/
|
||||
void System::InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
||||
{
|
||||
typedef BOOL (WINAPI * FPINITCRITEX)(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount, DWORD Flags);
|
||||
static FPINITCRITEX InitializeCriticalSectionEx = IsWindowsVistaOrGreater() ?
|
||||
(FPINITCRITEX)GetProcAddress(GetModuleHandle(L"Kernel32"), "InitializeCriticalSectionEx") : nullptr;
|
||||
static auto s_InitializeCriticalSectionEx = IsWindowsVistaOrGreater() ?
|
||||
(decltype(InitializeCriticalSectionEx)*)GetProcAddress(GetModuleHandle(L"kernel32"), "InitializeCriticalSectionEx") : nullptr;
|
||||
|
||||
if (InitializeCriticalSectionEx)
|
||||
if (s_InitializeCriticalSectionEx &&
|
||||
s_InitializeCriticalSectionEx(lpCriticalSection, 0, CRITICAL_SECTION_NO_DEBUG_INFO))
|
||||
{
|
||||
if (InitializeCriticalSectionEx(lpCriticalSection, 0, CRITICAL_SECTION_NO_DEBUG_INFO))
|
||||
{
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
::InitializeCriticalSectionAndSpinCount(lpCriticalSection, 0);
|
||||
InitializeCriticalSectionAndSpinCount(lpCriticalSection, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -91,28 +91,26 @@ void PlayerCAD::Initialize()
|
||||
this);
|
||||
|
||||
// Add WM_USER/WM_COPYDATA to allowed messages from lower level processes
|
||||
HMODULE hUser32 = LoadLibrary(L"user32.dll");
|
||||
if (hUser32)
|
||||
{
|
||||
// Try ChangeWindowMessageFilterEx first (Win7+)
|
||||
FPCHANGEWINDOWMESSAGEFILTEREX ChangeWindowMessageFilterEx = (FPCHANGEWINDOWMESSAGEFILTEREX)GetProcAddress(hUser32, "ChangeWindowMessageFilterEx");
|
||||
if (ChangeWindowMessageFilterEx)
|
||||
{
|
||||
ChangeWindowMessageFilterEx(m_Window, WM_USER, MSGFLT_ALLOW, nullptr);
|
||||
ChangeWindowMessageFilterEx(m_Window, WM_COPYDATA, MSGFLT_ALLOW, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try ChangeWindowMessageFilter (Vista)
|
||||
FPCHANGEWINDOWMESSAGEFILTER ChangeWindowMessageFilter = (FPCHANGEWINDOWMESSAGEFILTER)GetProcAddress(hUser32, "ChangeWindowMessageFilter");
|
||||
if (ChangeWindowMessageFilter)
|
||||
{
|
||||
ChangeWindowMessageFilter(WM_USER, MSGFLT_ALLOW);
|
||||
ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ALLOW);
|
||||
}
|
||||
}
|
||||
const HMODULE hUser32 = GetModuleHandle(L"user32");
|
||||
|
||||
FreeLibrary(hUser32);
|
||||
// Try ChangeWindowMessageFilterEx first (Win7+)
|
||||
auto changeWindowMessageFilterEx =
|
||||
(decltype(ChangeWindowMessageFilterEx)*)GetProcAddress(hUser32, "ChangeWindowMessageFilterEx");
|
||||
if (changeWindowMessageFilterEx)
|
||||
{
|
||||
changeWindowMessageFilterEx(m_Window, WM_USER, MSGFLT_ALLOW, nullptr);
|
||||
changeWindowMessageFilterEx(m_Window, WM_COPYDATA, MSGFLT_ALLOW, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try ChangeWindowMessageFilter (Vista)
|
||||
auto changeWindowMessageFilter =
|
||||
(decltype(ChangeWindowMessageFilter)*)GetProcAddress(hUser32, "ChangeWindowMessageFilter");
|
||||
if (changeWindowMessageFilter)
|
||||
{
|
||||
changeWindowMessageFilter(WM_USER, MSGFLT_ALLOW);
|
||||
changeWindowMessageFilter(WM_COPYDATA, MSGFLT_ALLOW);
|
||||
}
|
||||
}
|
||||
|
||||
WCHAR buffer[MAX_PATH];
|
||||
|
@ -21,9 +21,6 @@
|
||||
|
||||
#include "Player.h"
|
||||
|
||||
typedef BOOL (WINAPI * FPCHANGEWINDOWMESSAGEFILTER)(UINT message, DWORD dwFlag);
|
||||
typedef BOOL (WINAPI * FPCHANGEWINDOWMESSAGEFILTEREX)(HWND hWnd, UINT message, DWORD dwFlag, PCHANGEFILTERSTRUCT pChangeFilterStruct);
|
||||
|
||||
class PlayerCAD : public Player
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user