Edit

Share via


EnumerationOptions Constructors

Definition

Initializes a new instance of the EnumerationOptions class.

Overloads

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.

EnumerationOptions()

Source:
ManagementOptions.cs
Source:
ManagementOptions.cs
Source:
ManagementOptions.cs

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.

C#
public 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.

C#
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"]);
    }
}

Remarks

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

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

Source:
ManagementOptions.cs
Source:
ManagementOptions.cs
Source:
ManagementOptions.cs

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.

C#
public EnumerationOptions(System.Management.ManagementNamedValueCollection context, TimeSpan timeout, int blockSize, bool rewindable, bool returnImmediatley, bool useAmendedQualifiers, bool ensureLocatable, bool prototypeOnly, bool directRead, bool enumerateDeep);

Parameters

context
ManagementNamedValueCollection

The options context object containing provider-specific information that can be passed through to the provider.

timeout
TimeSpan

The time-out value for enumerating through the results.

blockSize
Int32

The number of items to retrieve at one time from WMI.

rewindable
Boolean

true to show that the result set is rewindable (allows multiple traversal); otherwise, false.

returnImmediatley
Boolean

true to show that the operation should return immediately (semi-sync) or block until all results are available; otherwise, false.

useAmendedQualifiers
Boolean

true to show that the returned objects should contain amended (locale-aware) qualifiers; otherwise, false.

ensureLocatable
Boolean

true to ensure all returned objects have valid paths; otherwise, false.

prototypeOnly
Boolean

true to return a prototype of the result set instead of the actual results; otherwise, false.

directRead
Boolean

true to retrieve objects of only the specified class or from derived classes as well; otherwise, false.

enumerateDeep
Boolean

true to use recursive enumeration in subclasses; otherwise, false.

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.

C#
using System;
using System.Management;
public class RemoteConnect
{
    public static void Main()
    {
        EnumerationOptions opt = new EnumerationOptions(
            null, System.TimeSpan.MaxValue,
            1, true, true, false,
            true, false, false, true);

        ManagementClass c = new ManagementClass("CIM_Service");
        foreach (ManagementObject o in c.GetInstances(opt))
            Console.WriteLine(o["Name"]);
    }
}

Remarks

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)