How to parse Explorer breadcrumb path like “This PC\Galaxy Tab A\Card\Folder1” using Windows Shell API?

爷,独闯天下 提交于 2020-01-23 06:21:25

问题


When a user has navigated in the Windows Explorer to e.g. a folder on the SD-card of his Android phone, the Explorer shows a kind of breadcrumb path like "This PC\Galaxy Tab A\Card\Folder1" when one clicks in the address bar.

Windows Explorer also accepts these kind of paths when entering or copying them in the address bar and pressing return.

I wonder if there is a way to parse these kind of breadcrumb paths using the Shell API and get a PItemIDList or IShellItem in return. So far I did not succeeed using e.g. SHParseDisplayName(). This code

LPITEMIDLIST itemidlist;
HRESULT hr = SHParseDisplayName(L"This PC\\Galaxy Tab A\\Card\\testfolder", NULL, &itemidlist, 0, NULL);

returned 0x80070002 as HRESULT.

The question SHParseDisplayName when path doesn't exists deals with the question how to use an IBindCtx to parse a path to a file that does not yet exists. This can be done using STR_FILE_SYS_BIND_DATA bind context. But the objects on a mobile device are no file system data and they do already exist, so I don't see why this is a duplicate.

来源:https://stackoverflow.com/questions/37000602/how-to-parse-explorer-breadcrumb-path-like-this-pc-galaxy-tab-a-card-folder1-u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!