I am having troubles using SHGetKnownFolderPath() function.
I am getting the following error message:
Type error in argument 1 to 'SHGetKnownFolderPath'; expected 'const struct _GUID *' but found 'struct _GUID'.
In the KnowFolders.h
we have the following relevant definitions:
#define DEFINE_KNOWN_FOLDER(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
EXTERN_C const GUID name
...
DEFINE_KNOWN_FOLDER(FOLDERID_ProgramFiles,0x905e63b6,0xc1bf,0x494e,0xb2,0x9c,0x65,0xb7,0x32,0xd3,0xd2,0x1a);
I am using Pelles C compiler .
This is my sample code:
#include <windows.h>
#include <wchar.h>
#include <KnownFolders.h>
#include <shlobj.h>
int wmain(int argc, wchar_t **argv) {
PWSTR path = NULL;
HRESULT hr = SHGetKnownFolderPath(FOLDERID_ProgramFiles, 0, NULL, &path);
if (SUCCEEDED(hr)){
wprintf(L"%ls", path);
}
CoTaskMemFree(path);
return 0;
}
How to fix this error message?
EDIT I have found code examples with SHGetKnownFolderPath(); all of them execute the function without the pointer. For instance:
hr = SHGetKnownFolderPath(FOLDERID_Public, 0, NULL, &pszPath);
if (SUCCEEDED(hr))
{
wprintf(L"FOLDERID_Public: %s\n", pszPath);
CoTaskMemFree(pszPath);
}