Export (0) Print
Expand All

ManagementObjectSearcher.ManagementObjectSearcher(ManagementScope, ObjectQuery, EnumerationOptions) Constructor

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
)
Not applicable.

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.

.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.

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());
        }
    }
}

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft