IFileDialog *pfd;
...
CoCreateInstance(CLSID_FileOpenDialog,NULL,
CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&pfd));
...
IShellItem *psiResult;
pfd->GetResult(&psiResult);
...
wchar_t *filepath;
psiResult->GetDisplayName(SIGDN_FILESYSPATH,&filepath);
...
This works perfectly well for regular files but fails (E_INVALIDARG) when the file is fetched via a Windows 7 library folder (the same file will work when accessed via it's normal path). The doc says that :
SIGDN_FILESYSPATH (Returns the item's file system path, if it has one. Only items that report SFGAO_FILESYSTEM have a file system path. When an item does not have a file system path, a call to IShellItem::GetDisplayName on that item will fail. In UI this name is suitable for display to the user in some cases, but note that it might not be specified for all items.
But using SIGDN_NORMALDISPLAY or all others SIGDN Enumeration fails too.
So how to get full path when the file is fetched via a Windows 7 libraries ?
EDIT 1
I can get the folder via :
IShellItem *psiResult;
pfd->GetFolder(& psiResult);
LPWSTR folderpath = NULL;
psiResult->GetDisplayName(SIGDN_FILESYSPATH, & folderpath);
But GetDisplayName() doesn't work with pfd->GetResult(& psiResult);
EDIT 2
I found what was not working, it was in CoInitializeEx. I used COINIT_MULTITHREADED, if I change it to COINIT_APARTMENTTHREADED it then works.