Bug 1842999 - Part 25: Support testing elements are present in resizable typed arrays...
[gecko.git] / mozglue / misc / GetKnownFolderPath.h
blob3fd80440ab995f4964064e553bf1bffbfe977b96
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_GetKnownFolderPath_h
6 #define mozilla_GetKnownFolderPath_h
8 #include <windows.h>
9 #include <objbase.h>
10 #include <shlobj.h>
12 #include "mozilla/glue/Debug.h"
13 #include "mozilla/UniquePtr.h"
15 namespace mozilla {
17 struct LoadedCoTaskMemFreeDeleter {
18 void operator()(void* ptr) {
19 static decltype(CoTaskMemFree)* coTaskMemFree = nullptr;
20 if (!coTaskMemFree) {
21 // Just let this get cleaned up when the process is terminated, because
22 // we're going to load it anyway elsewhere.
23 HMODULE ole32Dll = ::LoadLibraryW(L"ole32");
24 if (!ole32Dll) {
25 printf_stderr(
26 "Could not load ole32 - will not free with CoTaskMemFree");
27 return;
29 coTaskMemFree = reinterpret_cast<decltype(coTaskMemFree)>(
30 ::GetProcAddress(ole32Dll, "CoTaskMemFree"));
31 if (!coTaskMemFree) {
32 printf_stderr("Could not find CoTaskMemFree");
33 return;
36 coTaskMemFree(ptr);
40 UniquePtr<wchar_t, LoadedCoTaskMemFreeDeleter> GetKnownFolderPath(
41 REFKNOWNFOLDERID folderId);
43 } // namespace mozilla
45 #endif