PowerPlugin could unload the powrprof.dll even if some other skin was still using it. Fixed.

This commit is contained in:
Kimmo Pekkola 2009-11-01 10:00:12 +00:00
parent dcebc3bebd
commit 5d3d148b46
2 changed files with 14 additions and 10 deletions

View File

@ -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,6 +81,7 @@ FPCALLNTPOWERINFORMATION fpCallNtPowerInformation = NULL;
*/
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{
g_Instances++;
if (hDLL == NULL)
{
hDLL = LoadLibrary(L"powrprof.dll");
@ -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;
}
}

View File

@ -1,2 +1,2 @@
#pragma once
const int revision_number = 302;
const int revision_number = 304;