Browse Source

Weather: Maintain handle to uxtheme for the lifetime of the instance

pull/886/head
Valentin Radu 4 years ago
parent
commit
97e522cf34
  1. 18
      ep_weather_host/ep_weather_host.c
  2. 1
      ep_weather_host/ep_weather_host.h

18
ep_weather_host/ep_weather_host.c

@ -530,6 +530,10 @@ ULONG STDMETHODCALLTYPE epw_Weather_Release(EPWeather* _this)
CloseHandle(_this->hMutexData); CloseHandle(_this->hMutexData);
} }
if (_this->hUxtheme)
{
FreeLibrary(_this->hUxtheme);
}
FREE(_this); FREE(_this);
LONG dwOutstandingObjects = InterlockedDecrement(&epw_OutstandingObjects); LONG dwOutstandingObjects = InterlockedDecrement(&epw_OutstandingObjects);
LONG dwOutstandingLocks = InterlockedAdd(&epw_LockCount, 0); LONG dwOutstandingLocks = InterlockedAdd(&epw_LockCount, 0);
@ -1101,14 +1105,14 @@ HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName
InterlockedExchange64(&_this->dwGeolocationMode, dwGeolocationMode); InterlockedExchange64(&_this->dwGeolocationMode, dwGeolocationMode);
HMODULE hUxtheme = GetModuleHandleW(L"uxtheme.dll"); _this->hUxtheme = LoadLibraryW(L"uxtheme.dll");
if (hUxtheme) if (_this->hUxtheme)
{ {
RefreshImmersiveColorPolicyState = GetProcAddress(hUxtheme, (LPCSTR)104); RefreshImmersiveColorPolicyState = GetProcAddress(_this->hUxtheme, (LPCSTR)104);
SetPreferredAppMode = GetProcAddress(hUxtheme, (LPCSTR)135); SetPreferredAppMode = GetProcAddress(_this->hUxtheme, (LPCSTR)135);
AllowDarkModeForWindow = GetProcAddress(hUxtheme, (LPCSTR)133); AllowDarkModeForWindow = GetProcAddress(_this->hUxtheme, (LPCSTR)133);
ShouldAppsUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)132); ShouldAppsUseDarkMode = GetProcAddress(_this->hUxtheme, (LPCSTR)132);
ShouldSystemUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)138); ShouldSystemUseDarkMode = GetProcAddress(_this->hUxtheme, (LPCSTR)138);
if (ShouldAppsUseDarkMode && if (ShouldAppsUseDarkMode &&
ShouldSystemUseDarkMode && ShouldSystemUseDarkMode &&
SetPreferredAppMode && SetPreferredAppMode &&

1
ep_weather_host/ep_weather_host.h

@ -60,6 +60,7 @@ typedef interface EPWeather
char* pImage; char* pImage;
DWORD cbLocation; DWORD cbLocation;
LPCWSTR wszLocation; LPCWSTR wszLocation;
HMODULE hUxtheme;
RECT rcBorderThickness; // local variables: RECT rcBorderThickness; // local variables:
ITaskbarList* pTaskList; ITaskbarList* pTaskList;

Loading…
Cancel
Save