Robin Shalimov
January 15th, 2003, 01:55 PM
Hi!
Could somebody please help...
I have an LPITEMIDLIST returned by ::SHBrowserForFolder().
If it's not a virtual folder, I use ::SHGetPathFromIDList() to get the path.
But if it IS a virtual folder, the above-mentioned func returns an empty string.
How can I get a pathname to a virtual folder returned by ::SHBrowserForFolder?
Thanks :)
alex_gusev
January 20th, 2003, 06:30 AM
Hi,
try to do something like this:
LPITEMIDLIST il = SHBrowseForFolder(&bi);
if ( SHGetPathFromIDList(il,szDirName) )
sRes = CString(szDirName);
else
{
IShellFolder *ppshf = NULL;
HRESULT hr = SHGetDesktopFolder(&ppshf);
if ( SUCCEEDED(hr) )
{
IShellFolder *psfOut = NULL;
hr = ppshf->BindToObject(il,0,IID_IShellFolder,(void**)&psfOut);
if (SUCCEEDED(hr))
{
STRRET str;
TCHAR szDisplayName[MAX_PATH];
ppshf->GetDisplayNameOf(il,SHGDN_NORMAL, &str);
switch (str.uType)
{
case STRRET_CSTR:
TRACE("Folder is %s\n",str.cStr);
break;
case STRRET_WSTR:
{
char *pBuffer = NULL;
int nLen = WideCharToMultiByte(CP_ACP,0,str.pOleStr,-1,pBuffer,0,0,0);
if ( nLen )
{
pBuffer = new char[nLen];
WideCharToMultiByte(CP_ACP,0,str.pOleStr,-1,pBuffer,nLen,0,0);
TRACE("Folder is %s\n",pBuffer);
delete [] pBuffer;
pBuffer = NULL;
}
}
}
psfOut->Release();
}
}
Robin Shalimov
January 20th, 2003, 09:58 AM
Hi! And thanks for the answer :)
It returns sth like "Control Panel", or "My computer" but not the path. Anyway, I found out how to open virtual folders.
::ShellExecuteEx().
How to "convert" the PIDL returned by ::SHBrowseForFolder() to a CSIDL_XXX value is another question :)
Anyway, I guess I can call ::SHGetSpecialFolderLocation() in a loop, comparing the PIDL returned to my PIDL (returned by ::SHBrowseForFolder()).
Maybe there're some other ways...
Robin