Board index » cppbuilder » What is my PIDL?

What is my PIDL?


2007-03-22 11:10:01 AM
cppbuilder84
I've been looking at the SHBrowseForFolder() API call. But I can't
figure out how to set a "default" folder selection. I see that I can
send a BFFM_SETSELECTION message to the dialog, but The lParam parameter
is the PIDL of the folder to select.
So here's my question: Given "C:\My Dir\"; How do I get the PIDL?
Thanks in advance
DC
 
 

Re:What is my PIDL?

"DreamChaser" < XXXX@XXXXX.COM >wrote in message
Quote
I've been looking at the SHBrowseForFolder() API call.
But I can't figure out how to set a "default" folder selection.
You need to set a callback function via the lpfn member of the
BROWSEINFO structure. Inside the callback function, send a
BFFM_SETSELECTION message to the provided HWND.
Quote
The lParam parameter is the PIDL of the folder to select.
Only if you set the wParam value of the message to FALSE. If you set
it to TRUE instead, then you can specify the folder as a
null-terminated string instead. Note, however, that the dialog is
sensitive to trailing backslashes on the path if you use a string. If
the folder is the root of a drive, then you have to make sure that the
trailing backslash is present. If the folder is not the root, then
you have to strip off the trailing backslash instead. If you do not,
the folder will not be selected properly. This behavior is not
documented by Microsoft. I determined it over time when using
SHBrowseForFolder() in several different projects. Use a PIDL when
possible. It is more accurate.
Quote
Given "C:\My Dir\"; How do I get the PIDL?
Use SHGetDesktopFolder() to get an IShellFolder interface pointer for
the top-level Desktop namespace, and then pass the full folder path to
the IShellFolder::ParseDisplayName() method.
Gambit