|
-
January 15th, 2003, 02:55 PM
#1
How to convert LPITEMIDLIST to CSIDL
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
-
January 20th, 2003, 07:30 AM
#2
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();
}
}
Cheers,
Alex
 Please rate this post if you find it helpful 
-
January 20th, 2003, 10:58 AM
#3
Re: How to convert LPITEMIDLIST to CSIDL
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|