ManagementObjectSearcher Constructor (ManagementScope, ObjectQuery, EnumerationOptions)

Initializes a new instance of the ManagementObjectSearcher class to be used to invoke the specified query in the specified scope, with the specified options.

Namespace: System.Management
Assembly: System.Management (in system.management.dll)

public ManagementObjectSearcher (
	ManagementScope scope,
	ObjectQuery query,
	EnumerationOptions options
)
public ManagementObjectSearcher (
	ManagementScope scope, 
	ObjectQuery query, 
	EnumerationOptions options
)
public function ManagementObjectSearcher (
	scope : ManagementScope, 
	query : ObjectQuery, 
	options : EnumerationOptions
)

Parameters

scope

A ManagementScope specifying the scope of the query.

query

An ObjectQuery specifying the query to be invoked.

options

An EnumerationOptions specifying additional options to be used for the query.

The following example initializes a new instance of the ManagementObjectSearcher class with a specific query, scope, and enumeration options.

using System;
using System.Management;

public class Sample 
{
    public static void Main(string[] args) 
    {
        ManagementScope scope = 
            new ManagementScope("root\\CIMV2");
        SelectQuery q = 
            new SelectQuery("SELECT * FROM Win32_LogicalDisk");
        EnumerationOptions o = 
            new EnumerationOptions(
            null, System.TimeSpan.MaxValue,
            1, true, false, true, 
            true, false, true, true);
        ManagementObjectSearcher s = 
            new ManagementObjectSearcher(scope, q, o);

        foreach (ManagementObject disk in s.Get()) 
        {
            // show the disk instance
            Console.WriteLine(disk.ToString());
        }
    }
}

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: