Is there a better way to convert itemidlist to a path string than SHGetPathFromIDList ()?

Microsoft provides the CMFCShellTreeCtrl class to view the hierarchy of the shell namespace (essentially the same as the left side of the explorer window).

This control uses SHGetPathFromIDList() to go from the list of element identifiers to a string representation of the current path (selected element).

You can set the current element using any line that ends with the correspondence of its internal hierarchy of the shell, even if the involved objects are not "in the file system" - for example, \\WOLF will choose a WOLF machine under the node network (provided that your local network has machine named WOLF).

However, the interface responds with an empty string when you try to get such a path from the control due to its dependence on SHGetPathFromIDList() , which will not allow shell elements that are not in the file system.

Does anyone know of an implementation of the best ImprovedSHGetPathFromIDList() that works with ITEMIDLISTs arent 'on a file system (e.g. \ WOLF)?


I could provide my own version of SelectPath() and GetItemPath() for the shell tree control itself, implementing my own version of the ITEMIDLIST string logic so that the two are completely symmetrical (i.e. I would like GetItemPath (), to return the same path that was used to successfully select SelectPath () earlier - or for any node in the tree view).

However, it could be used elsewhere, as a generally improved round trip between path names and ITEMIDLIST (after all, UNC names are a fairly common way of expressing a file system path!)

+4
source share
1 answer

AFAIK, for elements that are not related to the file system, there is no ready-made function. You will need to go through ITEMIDLIST using IShellFolder::GetDisplayNameOf() for each item by specifying the SIGDN_PARENTRELATIVEPARSING or SIGDN_DESKTOPABSOLUTEPARSING flag to create a path line manually.

+2
source

Source: https://habr.com/ru/post/1469536/


All Articles