如题,在MSDN里面找到的安装虚拟硬盘路径, 但是Utility和ReturnCode这两个类没有引用,也不知道从何处来的。请教大神如何解答
using System;
using System.Management;
namespace HyperVSamples
{
class MountVHD
{
static void Mount(string path)
{
ManagementScope scope = new ManagementScope(@"root\virtualization", null);
ManagementObject imageService = Utility.GetServiceObject(scope, "Msvm_ImageManagementService");
ManagementBaseObject inParams = imageService.GetMethodParameters("Mount");
inParams["Path"] = path;
ManagementBaseObject outParams = imageService.InvokeMethod("Mount", inParams, null);
if ((UInt32)outParams["ReturnValue"] == ReturnCode.Started)
{
if (Utility.JobCompleted(outParams, scope))
{
Console.WriteLine("{0} was mounted successfully.", inParams["Path"]);
}
else
{
Console.WriteLine("Unable to mount {0}", inParams["Path"]);
}
}
inParams.Dispose();
outParams.Dispose();
imageService.Dispose();
}
static void Main(string[] args)
{
if (args != null && args.Length != 1)
{
Console.WriteLine("Usage: MountVHD vhdPath");
return;
}
Mount(args[0]);
}
}
}