How can I get the PIDL of a library from its GUID?
For example, if I have the GUID of the Documents library ("{7B0DB17D-9CD2-4A93-9733-46CC89022E7C}"), how can I convert that into the library's ID list?
I thought SHParseDisplayName
would do the job, but it returns "file not found."
Bear in mind that what I need is the PIDL of the library, not of its default folder.
This is straight C++, no .Net.
TIA
Edit: This is the code that works, from the response below (without error checks). guid
is a GUID string prepended with 'shell:::', eg, 'shell:::{7B0DB17D-9CD2-4A93-9733-46CC89022E7C}'.
IShellFolder* pDesktop;
LPITEMIDLIST pidl;
SHGetDesktopFolder(&pDesktop);
pDesktop->ParseDisplayName(nullptr, nullptr, guid, nullptr, &pidl, 0);
Edit 2: Even easier: SHParseDisplayName
works if the 'shell:::' is prepended:
SHParseDisplayName(guid, nullptr, &pidl, 0, nullptr);
According to the documentation for IShellFolder::ParseDisplayName
you can simply pass it a filename in the form ::{GUID}
if you are using the desktop folder.
Edit: the documentation appears to be incomplete, according to this answer you need to add shell:
to the start of the string.
p->ParseDisplayName(m_hWnd, NULL, _T("shell:::{7B0DB17D-9CD2-4A93-9733-46CC89022E7C}"), NULL, &pidl, NULL);
You want the function SHGetKnownFolderIDList .
{7B0DB17D-9CD2-4A93-9733-46CC89022E7C}
) For example:
PIDLIST_ABSOLUTE pidl;
HRESULT hr = SHGetKnownFolderItem(FOLDERID_DocumentsLibrary, 0, NULL, out pidl);
There are three shell functions for dealing with KNOWNFOLDERs
C:\\Users\\Chris\\Documents
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.