本文整理汇总了C#中System.Management.ManagementClass.GetPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementClass.GetPropertyValue方法的具体用法?C# ManagementClass.GetPropertyValue怎么用?C# ManagementClass.GetPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.ManagementClass
的用法示例。
在下文中一共展示了ManagementClass.GetPropertyValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Remove
public virtual void Remove(string propertyName)
{
if (this.parent.GetType() == typeof(ManagementObject))
{
ManagementClass class2 = new ManagementClass(this.parent.ClassPath);
this.parent.SetPropertyValue(propertyName, class2.GetPropertyValue(propertyName));
}
else
{
int errorCode = this.parent.wbemObject.Delete_(propertyName);
if (errorCode < 0)
{
if ((errorCode & 0xfffff000L) == 0x80041000L)
{
ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode);
}
else
{
Marshal.ThrowExceptionForHR(errorCode);
}
}
}
}
示例2: Remove
/// <summary>
/// <para>Removes a <see cref='System.Management.PropertyData'/> from the <see cref='System.Management.PropertyDataCollection'/>.</para>
/// </summary>
/// <param name='propertyName'>The name of the property to be removed.</param>
/// <remarks>
/// <para> Properties can only be removed from class definitions,
/// not from instances. This method is only valid when invoked on a property
/// collection in a <see cref='System.Management.ManagementClass'/>.</para>
/// </remarks>
/// <example>
/// <code lang='C#'>ManagementClass c = new ManagementClass("MyClass");
/// c.Properties.Remove("PropThatIDontWantOnThisClass");
/// </code>
/// <code lang='VB'>Dim c As New ManagementClass("MyClass")
/// c.Properties.Remove("PropThatIDontWantOnThisClass")
/// </code>
/// </example>
public virtual void Remove(string propertyName)
{
// On instances, reset the property to the default value for the class.
if (parent.GetType() == typeof(ManagementObject))
{
ManagementClass cls = new ManagementClass(parent.ClassPath);
parent.SetPropertyValue(propertyName, cls.GetPropertyValue(propertyName));
}
else
{
int status = parent.wbemObject.Delete_(propertyName);
if (status < 0)
{
if ((status & 0xfffff000) == 0x80041000)
ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
else
Marshal.ThrowExceptionForHR(status);
}
}
}
示例3: Remove
public virtual void Remove(string propertyName)
{
if (this.parent.GetType() != typeof(ManagementObject))
{
int num = this.parent.wbemObject.Delete_(propertyName);
if (num < 0)
{
if (((long)num & (long)-4096) != (long)-2147217408)
{
Marshal.ThrowExceptionForHR(num);
}
else
{
ManagementException.ThrowWithExtendedInfo((ManagementStatus)num);
return;
}
}
return;
}
else
{
ManagementClass managementClass = new ManagementClass(this.parent.ClassPath);
this.parent.SetPropertyValue(propertyName, managementClass.GetPropertyValue(propertyName));
return;
}
}