title: Retrieving virtual disk file name from disk number
body: <p>When I list virtual disks within diskpart:</p>
  
  <pre><code>DISKPART&gt; list vdisk
  
    VDisk ###  Disk ###  State                 Type       File
    ---------  --------  --------------------  ---------  ----
    VDisk 0    Disk 2    Attached not open     Fixed       C:\Disk.vhd
  </code></pre>
  
  <p>Interesting part for me here is file name. I tried to find equivalent of function that would give me file name (under File column) if I know disk number.</p>
  
  <p>Ideally, I would give "<strong>\\?\PhysicalDrive2</strong>" and I would get "<strong>C:\Disk.vhd</strong>" as result.</p>
  
  <p>I already tried:</p>
  
  <ol>
  <li>Using diskpart and parsing output - since it is undocumented format, it can change at any time. This is not something I would rely on.</li>
  <li>General <a href="http://msdn.microsoft.com/en-us/library/dd323700(v=VS.85).aspx" rel="nofollow noreferrer">VHD API</a> - no function takes disk number as parameter.</li>
  <li>Microsoft.Storage.Vds.dll - There are enumerations that go through each drive (e.g. Service.Providers) but there is no property/function that will give me name of source file.  While I can now be sure that e.g. drive D: is virtual drive, I still cannot know which .vhd file was attached.</li>
  </ol>
  
  <p>Any idea which  function that might be?</p>