8

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.

Community
  • 1
  • 1
Joachim Marder
  • 782
  • 5
  • 12
  • 1
    *"So far I did not succeeed using e.g. `SHParseDisplayName()`"* - What have you tried. How did it fail to meet your expectations? Besides that, what are you really trying to achieve? – IInspectable May 03 '16 at 09:47
  • `SHParseDisplayName()` failed with an error, I added the error code. What I am trying to achieve is to get a `PItemIdList or `IShellItem` for an Explorer breadcrumb path, which I need for Shell context menu operations. – Joachim Marder May 03 '16 at 10:34
  • Possible duplicate of [SHParseDisplayName when path doesn't exists](http://stackoverflow.com/questions/18576103/shparsedisplayname-when-path-doesnt-exists) – Simon Mourier May 03 '16 at 16:25
  • `0x80070002` is `HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)`. – Remy Lebeau May 03 '16 at 20:15
  • @RemyLebeau - yes, OP must pass a context like in your answer, that's why I think it's a duplicate – Simon Mourier May 04 '16 at 05:58
  • @Simon: I suspected that too, but what must the `IBindCtx` look like in case of mobile devices or a WebDAV folder? The `STR_FILE_SYS_BIND_DATA` referenced as example won't work. – Joachim Marder May 08 '16 at 18:20
  • It should work. You should show sample code and what error you get – Simon Mourier May 08 '16 at 20:23
  • @Simon: I added sample code, but that's one pretty straight forward line only, plus variable declaration plus includes. – Joachim Marder May 09 '16 at 12:29
  • As described in the duplicate, you *must* create an IBindCtx with CreateBindCtx, set its options to STR_FILE_SYS_BIND_DATA with SetBindOptions and pass it to SHParseDisplayName. You can't pass null – Simon Mourier May 09 '16 at 14:02
  • 2
    @Simon: Could you please explain why I should use `STR_FILE_SYS_BIND_DATA` for a non file system object? The [linked sample code at the ONT blog](https://blogs.msdn.microsoft.com/oldnewthing/20130503-00/?p=4463/) expects a "WIN32_FIND_DATAW" - where should that come from? The sample code fills its members for attributes and size, one reason for me to retrieve the ItemIdList of the object on the mobile device is that I want to query such metadata. – Joachim Marder May 09 '16 at 15:15
  • Does it work or not? Please read the duplicate question and answer – Simon Mourier May 09 '16 at 20:39
  • @Simon: I have read the duplicate question and answer multiple times. It simply does not fit my question, it deals with file system data, but objects on mobile device aren't file system data. Main reasons are: I don't want to create a simple PIDL for the file system and I don't have metadata to fill in the `WIN32_FIND_DATAW` struct, as it is the metadata that I want to query. Please respond to the question why I should use `STR_FILE_SYS_BIND_DATA` for a non file system object? – Joachim Marder May 10 '16 at 07:15

0 Answers0