編集

次の方法で共有


EnumerationOptions.BlockSize Property

Definition

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

public:
 property int BlockSize { int get(); void set(int value); };
public int BlockSize { get; set; }
member this.BlockSize : int with get, set
Public Property BlockSize As Integer

Property Value

The block size in block operations.

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();
        opt.BlockSize = 2;
        // 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
        opt.BlockSize = 2
        ' 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

Remarks

Property Value

The default value is 1.

.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