本文整理汇总了C#中System.Management.ManagementClass.GetSubclasses方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementClass.GetSubclasses方法的具体用法?C# ManagementClass.GetSubclasses怎么用?C# ManagementClass.GetSubclasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.ManagementClass
的用法示例。
在下文中一共展示了ManagementClass.GetSubclasses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WmiInformationGatherer
/// <summary>
/// Targets the specified namespace on a specified computer, and scavenges it for all classes, if the bool is set to true. If false, it is used to setup the ManagementPath which
/// consists of the specified system and specified namespace
/// </summary>
/// <param name="pNamespace"></param>
/// <param name="pHostName"></param>
public WmiInformationGatherer(string pNamespace, string pHostName, bool pScavenge)
{
mRemoteWmiPath = new ManagementPath(@"\\" + pHostName + @"\root\" + pNamespace);
if (pScavenge)
{
try
{
ManagementClass managementClass = new ManagementClass(mRemoteWmiPath);
EnumerationOptions scavengeOptions = new EnumerationOptions();
scavengeOptions.EnumerateDeep = false;
WmiResults = new WmiResult(pHostName);
WmiResults.PopulateClassesList(managementClass.GetSubclasses());
}
catch (Exception e)
{
WmiResults.WmiError = e;
}
}
}
示例2: RefreshClassListAsync
/// <summary>
/// Asynchronously refreshes the class list cache for the currently connected WMI Namespace.
/// </summary>
private void RefreshClassListAsync()
{
this.Text = String.Format("{0}{1}", WINDOW_TITLE_PREFIX, this.CurrentNamespacePath);
classListItems.Clear();
this.listViewClasses.Items.Clear();
this.Log(LogLevel.Information, String.Format("Loading classes for namespace: {0}", this.CurrentNamespacePath));
var path = new ManagementPath(this.CurrentNamespacePath);
var ns = new ManagementClass(this.CurrentNamespaceScope, path, nsObjGetOpts);
try
{
ns.GetSubclasses(classListObserver, classListEnumOpts);
this.Log(LogLevel.Success, "Finished loading classes.");
}
catch (ManagementException e)
{
var msg = String.Format("An error occurred listing classes in {0}:\r\n\r\n{1}", this.CurrentNamespacePath, e.Message);
this.Log(LogLevel.Critical, msg);
}
}