diff --git a/ep_weather_host/ep_weather_host.c b/ep_weather_host/ep_weather_host.c index b2d6b28..5deca54 100644 --- a/ep_weather_host/ep_weather_host.c +++ b/ep_weather_host/ep_weather_host.c @@ -530,6 +530,10 @@ ULONG STDMETHODCALLTYPE epw_Weather_Release(EPWeather* _this) CloseHandle(_this->hMutexData); } + if (_this->hUxtheme) + { + FreeLibrary(_this->hUxtheme); + } FREE(_this); LONG dwOutstandingObjects = InterlockedDecrement(&epw_OutstandingObjects); LONG dwOutstandingLocks = InterlockedAdd(&epw_LockCount, 0); @@ -1101,14 +1105,14 @@ HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName InterlockedExchange64(&_this->dwGeolocationMode, dwGeolocationMode); - HMODULE hUxtheme = GetModuleHandleW(L"uxtheme.dll"); - if (hUxtheme) + _this->hUxtheme = LoadLibraryW(L"uxtheme.dll"); + if (_this->hUxtheme) { - RefreshImmersiveColorPolicyState = GetProcAddress(hUxtheme, (LPCSTR)104); - SetPreferredAppMode = GetProcAddress(hUxtheme, (LPCSTR)135); - AllowDarkModeForWindow = GetProcAddress(hUxtheme, (LPCSTR)133); - ShouldAppsUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)132); - ShouldSystemUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)138); + RefreshImmersiveColorPolicyState = GetProcAddress(_this->hUxtheme, (LPCSTR)104); + SetPreferredAppMode = GetProcAddress(_this->hUxtheme, (LPCSTR)135); + AllowDarkModeForWindow = GetProcAddress(_this->hUxtheme, (LPCSTR)133); + ShouldAppsUseDarkMode = GetProcAddress(_this->hUxtheme, (LPCSTR)132); + ShouldSystemUseDarkMode = GetProcAddress(_this->hUxtheme, (LPCSTR)138); if (ShouldAppsUseDarkMode && ShouldSystemUseDarkMode && SetPreferredAppMode && diff --git a/ep_weather_host/ep_weather_host.h b/ep_weather_host/ep_weather_host.h index 3976647..37e7854 100644 --- a/ep_weather_host/ep_weather_host.h +++ b/ep_weather_host/ep_weather_host.h @@ -60,6 +60,7 @@ typedef interface EPWeather char* pImage; DWORD cbLocation; LPCWSTR wszLocation; + HMODULE hUxtheme; RECT rcBorderThickness; // local variables: ITaskbarList* pTaskList;