ManagementObjectSearcher 类

定义

基于指定的查询检索管理对象的集合。Retrieves a collection of management objects based on a specified query. 此类是用于检索管理信息的较为常用的入口点之一。This class is one of the more commonly used entry points to retrieving management information. 例如,它可以用于枚举系统中的所有磁盘驱动器、网络适配器、进程及更多管理对象,或者用于查询所有处于活动状态的网络连接以及暂停的服务等。For example, it can be used to enumerate all disk drives, network adapters, processes and many more management objects on a system, or to query for all network connections that are up, services that are paused, and so on. 在实例化之后,此类的实例可以接受在 ObjectQuery 或其派生类中表示的 WMI 查询作为输入,并且还可以选择接受一个 ManagementScope(表示执行查询时所在的 WMI 命名空间)。When instantiated, an instance of this class takes as input a WMI query represented in an ObjectQuery or its derivatives, and optionally a ManagementScope representing the WMI namespace to execute the query in. 它还可以接受 EnumerationOptions 中的其他高级选项。It can also take additional advanced options in an EnumerationOptions. 当调用此对象的 Get() 方法时,ManagementObjectSearcher 在指定的范围内执行给定的查询,并返回与 ManagementObjectCollection 中的查询匹配的管理对象的集合。When the Get() method on this object is invoked, the ManagementObjectSearcher executes the given query in the specified scope and returns a collection of management objects that match the query in a ManagementObjectCollection.

public ref class ManagementObjectSearcher : System::ComponentModel::Component
public class ManagementObjectSearcher : System.ComponentModel.Component
type ManagementObjectSearcher = class
    inherit Component
Public Class ManagementObjectSearcher
Inherits Component
继承
ManagementObjectSearcher

构造函数

ManagementObjectSearcher()

初始化 ManagementObjectSearcher 类的新实例。Initializes a new instance of the ManagementObjectSearcher class. 设置此对象的部分属性后,可以使用此对象调用对管理信息的查询。After some properties on this object are set, the object can be used to invoke a query for management information. 这就是无参数构造函数。This is the parameterless constructor.

ManagementObjectSearcher(ManagementScope, ObjectQuery)

初始化 ManagementObjectSearcher 类的一个新实例,它用于在指定范围内调用指定查询。Initializes a new instance of the ManagementObjectSearcher class used to invoke the specified query in the specified scope.

ManagementObjectSearcher(ManagementScope, ObjectQuery, EnumerationOptions)

使用指定的选项初始化 ManagementObjectSearcher 类的一个新实例,它将用于在指定范围内调用指定的查询。Initializes a new instance of the ManagementObjectSearcher class to be used to invoke the specified query in the specified scope, with the specified options.

ManagementObjectSearcher(ObjectQuery)

初始化 ManagementObjectSearcher 类的一个新实例,它用于调用有关管理信息的指定查询。Initializes a new instance of the ManagementObjectSearcher class used to invoke the specified query for management information.

ManagementObjectSearcher(String)

初始化 ManagementObjectSearcher 类的一个新实例,它用于调用有关管理信息的指定查询。Initializes a new instance of the ManagementObjectSearcher class used to invoke the specified query for management information.

ManagementObjectSearcher(String, String)

初始化 ManagementObjectSearcher 类的一个新实例,它用于在指定范围内调用指定查询。Initializes a new instance of the ManagementObjectSearcher class used to invoke the specified query in the specified scope.

ManagementObjectSearcher(String, String, EnumerationOptions)

初始化 ManagementObjectSearcher 类的一个新实例,它将用于在指定范围内使用指定选项调用指定的查询。Initializes a new instance of the ManagementObjectSearcher class used to invoke the specified query, in the specified scope, and with the specified options.

属性

CanRaiseEvents

获取一个指示组件是否可以引发事件的值。Gets a value indicating whether the component can raise an event.

(继承自 Component)
Container

获取 IContainer,它包含 ComponentGets the IContainer that contains the Component.

(继承自 Component)
DesignMode

获取一个值,用以指示 Component 当前是否处于设计模式。Gets a value that indicates whether the Component is currently in design mode.

(继承自 Component)
Events

获取附加到此 Component 的事件处理程序的列表。Gets the list of event handlers that are attached to this Component.

(继承自 Component)
Options

获取或设置有关如何搜索对象的选项。Gets or sets the options for how to search for objects.

Query

获取或设置要在搜索器中调用的查询(即搜索管理对象时要应用的条件)。Gets or sets the query to be invoked in the searcher (that is, the criteria to be applied to the search for management objects).

Scope

获取或设置要在其中查找对象的范围(该范围表示一个 WMI 命名空间)。Gets or sets the scope in which to look for objects (the scope represents a WMI namespace).

Site

获取或设置 ISiteComponentGets or sets the ISite of the Component.

(继承自 Component)

方法

CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
Dispose()

释放 Component 使用的所有资源。Releases all resources used by the Component.

(继承自 Component)
Dispose(Boolean)

释放 Component 使用的非托管资源,并选择性地释放托管资源。Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(继承自 Component)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
Get()

调用指定的 WMI 查询并返回结果集合。Invokes the specified WMI query and returns the resulting collection.

Get(ManagementOperationObserver)

异步调用 WMI 查询,并绑定到一个观察程序以传递结果。Invokes the WMI query asynchronously, and binds to a watcher to deliver the results.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetService(Type)

返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。Returns an object that represents a service provided by the Component or by its Container.

(继承自 Component)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
ToString()

返回包含 String 的名称的 Component(如果有)。Returns a String containing the name of the Component, if any. 不应重写此方法。This method should not be overridden.

(继承自 Component)

事件

Disposed

当通过调用 Dispose() 方法释放组件时发生。Occurs when the component is disposed by a call to the Dispose() method.

(继承自 Component)

适用于