【发布时间】:2022-04-29 12:01:27
【问题描述】:
这是我用来挂载 ISO 的代码
// With help of WMICodeCreator
ManagementObject mo = new ManagementObject("root\\Microsoft\\Windows\\Storage",
"MSFT_DiskImage.ImagePath='" + isoFile + "',StorageType=1",
null);
// Obtain in-parameters for the method
ManagementBaseObject inParams = mo.GetMethodParameters("Mount");
// Execute the method and obtain the return values.
ManagementBaseObject outParams = mo.InvokeMethod("Mount", inParams, null);
outParams 只返回一个布尔值,如文档中的 here 所述。
如果我发出这个命令:
mo.Get();
string device = mo.GetPropertyValue("DevicePath");
...设备字符串显示\\.\CDROM0。即使我安装了第二个 ISO,它也会显示此值。
【问题讨论】:
-
outParams 可能知道吗?
-
Mount具有指示是否需要驱动器号的参数。还有ImagePath属性。参考:docs.microsoft.com/en-us/previous-versions/windows/desktop/…
标签: c# windows wmi iso system.management