I tried to work something out of that and came up with this for anyone interested.
Code:
ITEMIDLIST* path_to_pidl (const TCHAR* path)
{
ITEMIDLIST* pidl;
LPSHELLFOLDER desktop;
HANDLE hr;
#ifndef _UNICODE
wchar_t wpath[MAX_PATH];
#endif
if (SUCCEEDED(SHGetDesktopFolder(&desktop))) {
#ifndef _UNICODE
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, -1, wpath, sizeof(wpath)/sizeof(*wpath));
hr = (HANDLE) desktop->lpVtbl->ParseDisplayName(desktop, NULL, NULL, wpath, NULL, &pidl, NULL);
#else
hr = (HANDLE) desktop->lpVtbl->ParseDisplayName(desktop, NULL, NULL, path, NULL, &pidl, NULL);
#endif
/* desktop->lpVtbl->Release(); */
if (FAILED(hr))
return NULL;
return pidl;
}
return NULL;
}
The Release method seems to take an argument so I don't know what to pass. The SHGetMalloc() function for freeing the PIDL is also deprecated. I also notcied there is no SHELLFOLDER type, just LPSHELLFOLDER. Jesus, Microsoft.
As it turns out though, this PIDL does not do what I want to do. It sets the root of the file browser dialog to be the folder represented by the PIDL so you can't go anywhere above it when I really just wanted that folder to be selected.
I guess I'll just have to force the user to keep navigating from the root every time they want to select a folder.