當前位置: 首頁>>代碼示例>>C#>>正文


C# ManagementClass.GetSubclasses方法代碼示例

本文整理匯總了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;
                }
            }
        }
開發者ID:Sparse,項目名稱:MultiRDP,代碼行數:26,代碼來源:WmiInformationGatherer.cs

示例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);
            }
        }
開發者ID:giapdangle,項目名稱:wmilab,代碼行數:26,代碼來源:frmMain.cs


注:本文中的System.Management.ManagementClass.GetSubclasses方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。