diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-02-19 10:00:25 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-02-19 10:00:25 +0100 |
commit | c7668971968e044e85446d79362d7744846efdd0 (patch) | |
tree | e2d5b4f54edebe1373684ceb007cad39f2399c0f /widget/windows/WinTaskbar.cpp | |
parent | 85edb1c711f7816ed1a30edd07b37d314fac216a (diff) | |
download | UXP-c7668971968e044e85446d79362d7744846efdd0.tar UXP-c7668971968e044e85446d79362d7744846efdd0.tar.gz UXP-c7668971968e044e85446d79362d7744846efdd0.tar.lz UXP-c7668971968e044e85446d79362d7744846efdd0.tar.xz UXP-c7668971968e044e85446d79362d7744846efdd0.zip |
Remove the use of GetProcAddress() for shell32
This avoids manually hooking into shell32.dll and using the native shell API instead.
Tag #22.
Diffstat (limited to 'widget/windows/WinTaskbar.cpp')
-rw-r--r-- | widget/windows/WinTaskbar.cpp | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/widget/windows/WinTaskbar.cpp b/widget/windows/WinTaskbar.cpp index a2c553dea..530cfd5b9 100644 --- a/widget/windows/WinTaskbar.cpp +++ b/widget/windows/WinTaskbar.cpp @@ -34,8 +34,6 @@ #include <propkey.h> #include <shellapi.h> -const wchar_t kShellLibraryName[] = L"shell32.dll"; - static NS_DEFINE_CID(kJumpListBuilderCID, NS_WIN_JUMPLISTBUILDER_CID); namespace { @@ -77,30 +75,14 @@ SetWindowAppUserModelProp(mozIDOMWindow *aParent, if (!toplevelHWND) return NS_ERROR_INVALID_ARG; - typedef HRESULT (WINAPI * SHGetPropertyStoreForWindowPtr) - (HWND hwnd, REFIID riid, void** ppv); - SHGetPropertyStoreForWindowPtr funcGetProStore = nullptr; - - HMODULE hDLL = ::LoadLibraryW(kShellLibraryName); - funcGetProStore = (SHGetPropertyStoreForWindowPtr) - GetProcAddress(hDLL, "SHGetPropertyStoreForWindow"); - - if (!funcGetProStore) { - FreeLibrary(hDLL); - return NS_ERROR_NO_INTERFACE; - } - - IPropertyStore* pPropStore; - if (FAILED(funcGetProStore(toplevelHWND, - IID_PPV_ARGS(&pPropStore)))) { - FreeLibrary(hDLL); + RefPtr<IPropertyStore> pPropStore; + if (FAILED(SHGetPropertyStoreForWindow(toplevelHWND, IID_IPropertyStore, + getter_AddRefs(pPropStore)))) { return NS_ERROR_INVALID_ARG; } PROPVARIANT pv; if (FAILED(InitPropVariantFromString(aIdentifier.get(), &pv))) { - pPropStore->Release(); - FreeLibrary(hDLL); return NS_ERROR_UNEXPECTED; } @@ -111,8 +93,6 @@ SetWindowAppUserModelProp(mozIDOMWindow *aParent, } PropVariantClear(&pv); - pPropStore->Release(); - FreeLibrary(hDLL); return rv; } @@ -339,30 +319,11 @@ WinTaskbar::GetDefaultGroupId(nsAString & aDefaultGroupId) { // (static) Called from AppShell bool WinTaskbar::RegisterAppUserModelID() { - SetCurrentProcessExplicitAppUserModelIDPtr funcAppUserModelID = nullptr; - bool retVal = false; - nsAutoString uid; if (!GetAppUserModelID(uid)) return false; - HMODULE hDLL = ::LoadLibraryW(kShellLibraryName); - - funcAppUserModelID = (SetCurrentProcessExplicitAppUserModelIDPtr) - GetProcAddress(hDLL, "SetCurrentProcessExplicitAppUserModelID"); - - if (!funcAppUserModelID) { - ::FreeLibrary(hDLL); - return false; - } - - if (SUCCEEDED(funcAppUserModelID(uid.get()))) - retVal = true; - - if (hDLL) - ::FreeLibrary(hDLL); - - return retVal; + return SUCCEEDED(SetCurrentProcessExplicitAppUserModelID(uid.get())); } NS_IMETHODIMP |