Bug 1323695 - Conflict SHLoadLibraryFromKnownFolder when bumping up to WINVER=0x0601. r?froydnj
When setting WINVER=0x601, we cannot compile SpecialSystemDirectory.cpp due to the following.
0:13.17 c:/Development/hg.mozilla.org/mozilla-inbound/xpcom/io/SpecialSystemDirectory.cpp(123): error C2084: function 'HRESULT SHLoadLibraryFromKnownFolder(const KNOWNFOLDERID &,DWORD,const IID &,void **)' already has a body
0:13.17 C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\shobjidl.h(32834): note: see previous definition of 'SHLoadLibraryFromKnownFolder'
0:13.17 c:/Development/hg.mozilla.org/mozilla-inbound/xpcom/io/SpecialSystemDirectory.cpp(158): error C2440: 'initializing': cannot convert from 'HRESULT (__cdecl *)(const KNOWNFOLDERID &,DWORD,const IID &,void **)' to 'HRESULT'
0:13.17 c:/Development/hg.mozilla.org/mozilla-inbound/xpcom/io/SpecialSystemDirectory.cpp(158): note: There is no context in which this conversion is possible
MozReview-Commit-ID: 2KZEzcn21S7
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -111,16 +111,17 @@ GetWindowsFolder(int aFolder, nsIFile**
if (len > 1 && path[len - 1] != L'\\') {
path[len] = L'\\';
path[++len] = L'\0';
}
return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
}
+#if WINVER < 0x0601
__inline HRESULT
SHLoadLibraryFromKnownFolder(REFKNOWNFOLDERID aFolderId, DWORD aMode,
REFIID riid, void** ppv)
{
*ppv = nullptr;
IShellLibrary* plib;
HRESULT hr = CoCreateInstance(CLSID_ShellLibrary, nullptr,
CLSCTX_INPROC_SERVER,
@@ -129,16 +130,17 @@ SHLoadLibraryFromKnownFolder(REFKNOWNFOL
hr = plib->LoadLibraryFromKnownFolder(aFolderId, aMode);
if (SUCCEEDED(hr)) {
hr = plib->QueryInterface(riid, ppv);
}
plib->Release();
}
return hr;
}
+#endif
/*
* Check to see if we're on Win7 and up, and if so, returns the default
* save-to location for the Windows Library passed in through aFolderId.
* Otherwise falls back on pre-win7 GetWindowsFolder.
*/
static nsresult
GetLibrarySaveToPath(int aFallbackFolderId, REFKNOWNFOLDERID aFolderId,