1

Is there a way to retrieve a list of all virtual disks attached on a Windows machine? I mean all paths to VHD/VHDX mounted by disk manager.

There is an undocumented function GetAllAttachedVirtualDiskPhysicalPaths that does exactly that, however it's not available in Windows 8 (only in 8.1). I need Win 8 support.

Thanks

Isso
  • 1,285
  • 11
  • 23

2 Answers2

1

I don't know of direct c++ calls, assuming you don't know the VD handles but want to get all mounted disks not created or handled by your own code. There is a rough way to do it by running a

  diskpart
  list vdisk

script and pipe the result into a text file, which you can then parse with c++ to get the list.

  • 1
    this internally called `IVdsVdProvider::QueryVDisks` - always better call api and comiterfaces direct yourself – RbMm Mar 24 '18 at 19:24
0

Thanks to @Stacking For Heap for the hint - with API monitoring I figured that Diskpart uses VDS API for that purpose, namely IVdsVdProvider. Just built and tested the code - it works fine.

Similar approach is used here, with code samples:

Retrieving virtual disk file name from disk number

Isso
  • 1,285
  • 11
  • 23