Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ManagementObject Constructor (ManagementPath, ObjectGetOptions)

Initializes a new instance of the ManagementObject class bound to the specified WMI path, including the specified additional options.

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

public ManagementObject(
	ManagementPath path,
	ObjectGetOptions options
)

Parameters

path
Type: System.Management.ManagementPath

A ManagementPath containing the WMI path.

options
Type: System.Management.ObjectGetOptions

An ObjectGetOptions containing additional options for binding to the WMI object. This parameter could be null if default options are to be used.

.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 ManagementObject class that is bound to a specific WMI path.

using System;
using System.Management;

class Sample
{
    public static int Main(string[] args) 
    {
        ManagementPath p = 
            new ManagementPath("Win32_Service");

        // Set options for no context info 
        // but requests amended qualifiers  
        // to be contained in the object
        ObjectGetOptions opt = 
            new ObjectGetOptions(
            null, System.TimeSpan.MaxValue, true);    

        ManagementClass c = 
            new ManagementClass(p, opt);

        Console.WriteLine(
            c.Qualifiers["Description"].Value);

        return 0;
    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft