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
12 #include "mozilla/glue/Debug.h"
13 #include "mozilla/UniquePtr.h"
17 struct LoadedCoTaskMemFreeDeleter
{
18 void operator()(void* ptr
) {
19 static decltype(CoTaskMemFree
)* coTaskMemFree
= nullptr;
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");
26 "Could not load ole32 - will not free with CoTaskMemFree");
29 coTaskMemFree
= reinterpret_cast<decltype(coTaskMemFree
)>(
30 ::GetProcAddress(ole32Dll
, "CoTaskMemFree"));
32 printf_stderr("Could not find CoTaskMemFree");
40 UniquePtr
<wchar_t, LoadedCoTaskMemFreeDeleter
> GetKnownFolderPath(
41 REFKNOWNFOLDERID folderId
);
43 } // namespace mozilla