5

I'm trying to figure out, how to get a PIDL (or IShellItem, or IShellFolder) of a volume Guid Path (e.g. "\\?\Volume{50165421-0000-0000-0000-005d25000000}\"). I would like to be able to invoke file operations or shell context menu items from my program on it or its child objects. If it is mounted and accessible via drive letter or folder, no problem, but I'm struggling with unmounted volumes.
While the addressbar of Windows Explorer is not able to parse these names, it is possible to open Windows Explorer with the run command (or use ShellExecute):

  • Via "Disk Management", create a new volume, without assigning a drive-letter or folder:Create volume without drive
  • using mountvol, you can see the Volume name with "no mount points" (1)
  • Copy the volume path into a run command (2)
  • See Windows Explorer (3) Open volume in Explorer

Once opened in Windows Explorer, it can handle the paths fine, i.e. enumeration and context menu works normally.

What I've tried so far:

Actually I did NOT check a lot of IBindCtx options, because from the documentation I'm not sure, which ones to try out for this use case.

  • Tried the undocumented IShellURL interface shared by @RbMm here -- it displays the same error message box as the AddressBar.

  • From Volume Management Reference I also do not see a connection point towards PIDLs.

  • Tracking the starting of the volume name with ShellExecute with Process Monitor, I see that Windows Explorer is accessing

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\?\Volume{50165421-0000-0000-0000-005D25000000}, just before opening "\Device\HarddiskVolume3\". But I'm not even sure, if this is related.

Does anyone have an idea what else I could try?

sbne
  • 51
  • 4
  • AFAIK, there is no volume item in the shell namespace. A volume can have multiple drive letters (C:\, D:\, etc.) and they are children of MyComputer. They can be accessed simply using `SHCreateItemFromParsingName(L"d:\\")` for example. Use `GetVolumePathNamesForVolumeName` to get all drive letters for a volume: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumepathnamesforvolumenamew – Simon Mourier Jul 08 '21 at 17:27
  • Thank you @SimonMourier. I'm sorry I forgot one detail: I'm trying to find a solution for an unmounted volume; edited the question. Seems that there must be some way to get some Shell interface to it, since once opened in File Explorer, everything works. – sbne Jul 08 '21 at 17:43
  • Volume dont have pidls; only drives. Are you see volume in Explorer? – user2120666 Jul 08 '21 at 19:46
  • What do you mean by "an unmounted volume" that you can open in File Explorer? How do you do that exactly? – Simon Mourier Jul 08 '21 at 20:08
  • @SimonMourier: With "unmounted" I mean volumes that are attached, but do not have assigned a drive letter or a folder. Like the one that you see in the mountvol output here: https://superuser.com/a/465741/962894. You can use the run dialog on any of these Volume Guid paths, no matter if they have a mount point or not. – sbne Jul 09 '21 at 07:57
  • @user2120666: I've added steps/screenshots to clarify. Windows Explorer is clearly able to open/show/handle the volume just fine. The question is how does it manage to get an ItemIdList or ShellItem from this kind of path to do so? – sbne Jul 09 '21 at 09:06
  • 3
    You could open the item using ShellExecute and get the PIDL from the view, that works (but opens a view...). Otherwise, I don't know of a documented way, but here is sample that should work (adapt to your guids) https://pastebin.com/raw/wZZuAgkN – Simon Mourier Jul 09 '21 at 15:59
  • Hi @SimonMourier: this works, thank you very much! How do you know such things? Is there a way I could have figured it out? – sbne Jul 19 '21 at 15:45
  • Just looking at the pidl :-) – Simon Mourier Jul 20 '21 at 08:13

0 Answers0