本文整理汇总了C#中System.Management.ManagementObject.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementObject.GetText方法的具体用法?C# ManagementObject.GetText怎么用?C# ManagementObject.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.ManagementObject
的用法示例。
在下文中一共展示了ManagementObject.GetText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModifyDevice
public static int ModifyDevice(this ManagementObject VM, ManagementObject Device, out ManagementObject Job)
{
Job = null;
switch (VM["__CLASS"].ToString().ToUpperInvariant())
{
case "MSVM_COMPUTERSYSTEM":
ManagementObject ServiceObj = GetServiceObject(VM.GetScope(), ServiceNames.VSManagement);
Job = new ManagementObject();
return (Int32)ServiceObj.InvokeMethod("ModifyVirtualSystemResources",
new object[] { VM.Path.Path, Device.GetText(TextFormat.WmiDtd20), null, Job });
default:
return -1;
}
}
示例2: AddDevice
public static ManagementObject AddDevice(this ManagementObject VM, ManagementObject Device)
{
switch (VM["__CLASS"].ToString().ToUpperInvariant())
{
case "MSVM_COMPUTERSYSTEM":
ManagementObject ServiceObj = GetServiceObject(VM.GetScope(), ServiceNames.VSManagement);
ManagementBaseObject inputs = ServiceObj.GetMethodParameters("AddVirtualSystemResources");
inputs["TargetSystem"] = VM.Path.Path;
inputs["ResourceSettingData"] = new string[]{Device.GetText(TextFormat.WmiDtd20)};
var result = ServiceObj.InvokeMethod("AddVirtualSystemResources", inputs, null);
switch (Int32.Parse(result["ReturnValue"].ToString()))
{
case (int)ReturnCodes.OK:
var tmp = result["NewResources"];
return GetObject(((string[])result["NewResources"]).First());
case (int)ReturnCodes.JobStarted:
var job = GetObject(result["Job"].ToString());
var r = WaitForJob(job);
if (r == 0)
{
var res = result["NewResources"];
var arr = (string[])res;
var path = arr.First();
var o = GetObject(path);
return GetObject(((string[])result["NewResources"]).First());
}
var jobres = job.InvokeMethod("GetError", new ManagementObject(), null);
var errStr = jobres["Error"].ToString();
var errObj = GetObject(errStr);
return null;
default:
return null;
}
default:
return null;
}
}
示例3: GetMofFormat
private static string GetMofFormat(ManagementObject obj)
{
return string.Concat(obj.GetText(TextFormat.Mof).Replace("\n", "\r\n"), "\r\n");
}
示例4: AddVirtualMachineResources
private ManagementObject AddVirtualMachineResources(ManagementObject objVm, ManagementObject resource)
{
if (resource == null)
return resource;
// request management service
ManagementObject objVmsvc = GetVirtualSystemManagementService();
// add resources
string txtResource = resource.GetText(TextFormat.CimDtd20);
ManagementBaseObject inParams = objVmsvc.GetMethodParameters("AddVirtualSystemResources");
inParams["TargetSystem"] = objVm;
inParams["ResourceSettingData"] = new string[] { txtResource };
ManagementBaseObject outParams = objVmsvc.InvokeMethod("AddVirtualSystemResources", inParams, null);
JobResult result = CreateJobResultFromWmiMethodResults(outParams);
if (result.ReturnValue == ReturnCode.OK)
{
string[] wmiPaths = (string[])outParams["NewResources"];
return wmi.GetWmiObjectByPath(wmiPaths[0]);
}
else if (result.ReturnValue == ReturnCode.JobStarted)
{
if (JobCompleted(result.Job))
{
string[] wmiPaths = (string[])outParams["NewResources"];
return wmi.GetWmiObjectByPath(wmiPaths[0]);
}
else
{
throw new Exception("Cannot add virtual machine resources");
}
}
else
{
throw new Exception("Cannot add virtual machine resources: " + txtResource);
}
}
示例5: GetMofFormat
static string GetMofFormat(ManagementObject obj)
{
return obj.GetText(TextFormat.Mof).Replace("\n", "\r\n") + "\r\n";
}