Retrieving virtual disk file name from disk number

后端 未结 4 1412
囚心锁ツ
囚心锁ツ 2020-12-25 08:53

When I list virtual disks within diskpart:

DISKPART> list vdisk

  VDisk ###  Disk ###  State                 Type       File
  ---------  --------  -----         


        
4条回答
  •  时光说笑
    2020-12-25 09:15

    There is no official managed .NET wrapper for the virtual disk APIs. So you currently have three options:

    1. Run the dos command and scrape the console response, which you don't want to do as it is not a stable API.

    2. UseMicrosoft.Storage.Vds.dll that was added in Server 2008. You can use .NET reflector to examine the API. However, this is also unofficial, in that it is undocumented and thus could change without warning in service packs, etc.

    3. Use the official C API. This is what I would recommend until an official managed wrapper class is released and documented. As noted above, the full API documentation has everything you need. I would recommend writing a simplified C wrapper dll around this API that does what you need and no more. Then, PInvoke your wrapper library.

提交回复
热议问题