当前位置: 首页>>代码示例>>C#>>正文


C# ManagementClass.GetPropertyValue方法代码示例

本文整理汇总了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);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:PropertyDataCollection.cs

示例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);
				}
			}
		}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:38,代码来源:PropertySet.cs

示例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;
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:26,代码来源:PropertyDataCollection.cs


注:本文中的System.Management.ManagementClass.GetPropertyValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。