EnumerationOptions 类


为查询和枚举相关的选项对象提供基类。Provides a base class for query and enumeration-related options objects.

public ref class EnumerationOptions : System::Management::ManagementOptions
public class EnumerationOptions : System.Management.ManagementOptions
type EnumerationOptions = class
    inherit ManagementOptions
Public Class EnumerationOptions
Inherits ManagementOptions


下面的示例 EnumerationOptions 使用构造函数初始化变量 EnumerationOptions ,然后获取 WMI 类及其子类的所有实例。The following example initializes an EnumerationOptions variable with an EnumerationOptions constructor and then gets all the instances of a WMI class and its subclasses.

using System;
using System.Management;
public class RemoteConnect
    public static void Main()
        EnumerationOptions opt = new EnumerationOptions();
        // Will enumerate instances of the given class
        // and any subclasses.
        opt.EnumerateDeep = true;
        ManagementClass c = new ManagementClass("CIM_Service");
        foreach (ManagementObject o in c.GetInstances(opt))
Imports System.Management
Public Class RemoteConnect

    Public Overloads Shared Function Main( _
    ByVal args() As String) As Integer

        Dim opt As New EnumerationOptions
        ' Will enumerate instances of the given class
        ' and any subclasses.
        opt.EnumerateDeep = True
        Dim mngmtClass As New ManagementClass("CIM_Service")
        Dim o As ManagementObject
        For Each o In mngmtClass.GetInstances(opt)
        Next o

        Return 0
    End Function
End Class



使用默认值(有关默认值的内容,请参见各属性的说明)初始化 EnumerationOptions 类的新实例。Initializes a new instance of the EnumerationOptions class with default values (see the individual property descriptions for what the default values are). 这是无参数构造函数。This is the parameterless constructor.

EnumerationOptions(ManagementNamedValueCollection, TimeSpan, Int32, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean)

初始化将用于查询或枚举的 EnumerationOptions 类的一个新实例,从而允许用户指定不同选项的值。Initializes a new instance of the EnumerationOptions class to be used for queries or enumerations, allowing the user to specify values for the different options.



获取或设置块操作的块大小。Gets or sets the block size for block operations. 在对整个集合进行枚举时,WMI 将按指定大小的组返回结果。When enumerating through a collection, WMI will return results in groups of the specified size.


获取或设置一个 WMI 上下文对象。Gets or sets a WMI context object. 这是将传递给 WMI 提供程序的名称-值对列表,该提供程序支持自定义操作的上下文信息。This is a name-value pairs list to be passed through to a WMI provider that supports context information for customized operation.

(继承自 ManagementOptions)

获取或设置一个值,该值指示是否为指定类请求直接访问 WMI 提供程序,而不考虑其超类或派生类。Gets or sets a value indicating whether direct access to the WMI provider is requested for the specified class, without any regard to its super class or derived classes.


获取或设置一个值,该值指示返回的对象中是否应该有可定位信息。Gets or sets a value indicating whether to the objects returned should have locatable information in them. 这可确保系统属性(如“__PATH”、“__RELPATH”和“__SERVER”)非 null。This ensures that the system properties, such as __PATH, __RELPATH, and __SERVER, are non-NULL. 此标志只能用在查询中,而在枚举中会被忽略。This flag can only be used in queries, and is ignored in enumerations.


获取或设置一个值,该值指示是否将递归枚举请求到从指定的超类派生的所有类中。Gets or sets a value indicating whether recursive enumeration is requested into all classes derived from the specified superclass. 如果为 false,则仅返回直接派生类成员。If false, only immediate derived class members are returned.


获取或设置一个值,该值指示查询是否应返回结果集的原型而不返回实际结果。Gets or sets a value indicating whether the query should return a prototype of the result set instead of the actual results. 此标志用于获取原型。This flag is used for prototyping.


获取或设置一个值,该值指示调用的操作应以同步方式或半同步方式执行。Gets or sets a value indicating whether the invoked operation should be performed in a synchronous or semisynchronous fashion. 如果此属性设置为 true,则会调用枚举,并且调用会立即返回。If this property is set to true, the enumeration is invoked and the call returns immediately. 遍历结果集合后,将出现实际的检索结果。The actual retrieval of the results will occur when the resulting collection is walked.


获取或设置一个值,该值指示是否将集合假定为可重绕。Gets or sets a value indicating whether the collection is assumed to be rewindable. 如果为 true,则集合中的对象将保持以便用于多次枚举。If true, the objects in the collection will be kept available for multiple enumerations. 如果为 false,则只能将集合枚举一次。If false, the collection can only be enumerated one time.


获取或设置要应用于该操作的超时。Gets or sets the time-out to apply to the operation. 注意,对于返回集合的操作,此超时将通过结果集合(而不是操作本身)应用于枚举(对于后面一种情况,应使用 ReturnImmediately 属性)。Note that for operations that return collections, this time-out applies to the enumeration through the resulting collection, not the operation itself (the ReturnImmediately property is used for the latter). 此属性用来指示将以半同步方式执行操作。This property is used to indicate that the operation should be performed semi-synchronously.

(继承自 ManagementOptions)

获取或设置一个值,该值指示从 WMI 返回的对象是否应包含已修正信息。Gets or sets a value indicating whether the objects returned from WMI should contain amended information. 通常,已修正信息就是附加在 WMI 对象上的可本地化信息,如对象和属性说明。Typically, amended information is localizable information attached to the WMI object, such as object and property descriptions.



返回对象的一个副本。Returns a copy of the object.


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

(继承自 Object)

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

(继承自 Object)

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

(继承自 Object)

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

(继承自 Object)

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)