Editar

Compartilhar via


EnumerationOptions Class

Definition

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
Inheritance
EnumerationOptions

Examples

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))
            Console.WriteLine(o["Name"]);
    }
}
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)
            Console.WriteLine(o("Name"))
        Next o

        Return 0
    End Function
End Class

Constructors

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)

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.

Properties

BlockSize

Gets or sets the block size for block operations. When enumerating through a collection, WMI will return results in groups of the specified size.

Context

Gets or sets a WMI context object. This is a name-value pairs list to be passed through to a WMI provider that supports context information for customized operation.

(Inherited from ManagementOptions)
DirectRead

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.

EnsureLocatable

Gets or sets a value indicating whether to the objects returned should have locatable information in them. 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.

EnumerateDeep

Gets or sets a value indicating whether recursive enumeration is requested into all classes derived from the specified superclass. If false, only immediate derived class members are returned.

PrototypeOnly

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.

ReturnImmediately

Gets or sets a value indicating whether the invoked operation should be performed in a synchronous or semisynchronous fashion. 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.

Rewindable

Gets or sets a value indicating whether the collection is assumed to be rewindable. If true, the objects in the collection will be kept available for multiple enumerations. If false, the collection can only be enumerated one time.

Timeout

Gets or sets the time-out to apply to the operation. 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.

(Inherited from ManagementOptions)
UseAmendedQualifiers

Gets or sets a value indicating whether the objects returned from WMI should contain amended information. Typically, amended information is localizable information attached to the WMI object, such as object and property descriptions.

Methods

Clone()

Returns a copy of the object.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to