mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
PowerPlugin could unload the powrprof.dll even if some other skin was still using it. Fixed.
This commit is contained in:
parent
dcebc3bebd
commit
5d3d148b46
@ -64,6 +64,7 @@ enum POWER_STATE
|
||||
std::map<UINT, POWER_STATE> g_States;
|
||||
std::map<UINT, std::wstring> g_Formats;
|
||||
HINSTANCE hDLL = NULL;
|
||||
int g_Instances = 0;
|
||||
FPCALLNTPOWERINFORMATION fpCallNtPowerInformation = NULL;
|
||||
|
||||
/*
|
||||
@ -80,14 +81,15 @@ FPCALLNTPOWERINFORMATION fpCallNtPowerInformation = NULL;
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
if (hDLL == NULL)
|
||||
{
|
||||
hDLL = LoadLibrary(L"powrprof.dll");
|
||||
if (hDLL)
|
||||
{
|
||||
fpCallNtPowerInformation = (FPCALLNTPOWERINFORMATION)GetProcAddress(hDLL, "CallNtPowerInformation");
|
||||
}
|
||||
}
|
||||
g_Instances++;
|
||||
if (hDLL == NULL)
|
||||
{
|
||||
hDLL = LoadLibrary(L"powrprof.dll");
|
||||
if (hDLL)
|
||||
{
|
||||
fpCallNtPowerInformation = (FPCALLNTPOWERINFORMATION)GetProcAddress(hDLL, "CallNtPowerInformation");
|
||||
}
|
||||
}
|
||||
|
||||
POWER_STATE powerState = POWER_UNKNOWN;
|
||||
|
||||
@ -285,10 +287,12 @@ void Finalize(HMODULE instance, UINT id)
|
||||
g_Formats.erase(i2);
|
||||
}
|
||||
|
||||
if (hDLL != NULL)
|
||||
g_Instances--;
|
||||
if (hDLL != NULL && g_Instances == 0)
|
||||
{
|
||||
FreeLibrary(hDLL);
|
||||
hDLL = NULL;
|
||||
fpCallNtPowerInformation = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
#pragma once
|
||||
const int revision_number = 302;
|
||||
const int revision_number = 304;
|
Loading…
Reference in New Issue
Block a user