ManagementObject コンストラクター

定義

ManagementObject クラスの新しいインスタンスを初期化します。

オーバーロード

ManagementObject()

ManagementObject クラスの新しいインスタンスを初期化します。 これはパラメーターなしのコンストラクターです。

ManagementObject(ManagementPath)

指定した WMI (Windows Management Instrumentation) オブジェクト パスの ManagementObject クラスの新しいインスタンスを初期化します。 パスは、ManagementPath として指定します。

ManagementObject(String)

指定した WMI (Windows Management Instrumentation) オブジェクト パスの ManagementObject クラスの新しいインスタンスを初期化します。 パスは、文字列として指定します。

ManagementObject(ManagementPath, ObjectGetOptions)

指定した追加のオプションを含む、指定した WMI パスにバインドする ManagementObject クラスの新しいインスタンスを初期化します。

ManagementObject(SerializationInfo, StreamingContext)
古い.

ManagementObject クラスのシリアル化可能な新しいインスタンスを初期化します。

ManagementObject(String, ObjectGetOptions)

指定した追加のオプションを含む、指定した WMI パスにバインドする ManagementObject クラスの新しいインスタンスを初期化します。 このバリアントでは、パスは文字列として指定できます。

ManagementObject(ManagementScope, ManagementPath, ObjectGetOptions)

指定したオプションを含む、指定した WMI パスにバインドする ManagementObject クラスの新しいインスタンスを初期化します。

ManagementObject(String, String, ObjectGetOptions)

指定したオプションを含む、指定した WMI パスにバインドする ManagementObject クラスの新しいインスタンスを初期化します。 スコープとパスは、文字列として指定します。

ManagementObject()

ソース:
ManagementObject.cs
ソース:
ManagementObject.cs
ソース:
ManagementObject.cs

ManagementObject クラスの新しいインスタンスを初期化します。 これはパラメーターなしのコンストラクターです。

public:
 ManagementObject();
public ManagementObject ();
Public Sub New ()

次の例では、パラメーターなしのコンストラクターを使用して、 ManagementObject クラスの新しいインスタンスを初期化します。

using System;
using System.Management;

class Sample
{
    public static int Main(string[] args)
    {
        ManagementObject o = new ManagementObject();

        // Now set the path on this object to
        // bind it to a 'real' manageable entity
        o.Path =
            new ManagementPath("Win32_LogicalDisk='c:'");

        //Now it can be used
        Console.WriteLine(o["FreeSpace"]);

        return 0;
    }
}
Imports System.Management

Class Sample_ManagementClass
    Public Overloads Shared Function Main( _
        ByVal args() As String) As Integer

        Dim o As New ManagementObject

        Dim mp As New _
            ManagementPath("Win32_LogicalDisk='c:'")

        ' Now set the path on this object to
        ' bind it to a 'real' manageable entity
        o.Path = mp

        'Now it can be used 
        Console.WriteLine(o("FreeSpace"))

        Return 0
    End Function
End Class

注釈

.NET Framework のセキュリティ

直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。

適用対象

ManagementObject(ManagementPath)

ソース:
ManagementObject.cs
ソース:
ManagementObject.cs
ソース:
ManagementObject.cs

指定した WMI (Windows Management Instrumentation) オブジェクト パスの ManagementObject クラスの新しいインスタンスを初期化します。 パスは、ManagementPath として指定します。

public:
 ManagementObject(System::Management::ManagementPath ^ path);
public ManagementObject (System.Management.ManagementPath path);
new System.Management.ManagementObject : System.Management.ManagementPath -> System.Management.ManagementObject
Public Sub New (path As ManagementPath)

パラメーター

path
ManagementPath

WMI オブジェクトのパスを格納している ManagementPath

次の例では、指定した WMI オブジェクト パスを使用して ManagementObject 、 クラスの新しいインスタンスを初期化します。

using System;
using System.Management;

class Sample
{
    public static int Main(string[] args)
    {
        ManagementPath p =
            new ManagementPath(
            "Win32_Service.Name='Alerter'");
        ManagementObject o = new ManagementObject(p);

        //Now it can be used
        Console.WriteLine(o["Name"]);

        return 0;
    }
}
Imports System.Management

Class Sample_ManagementClass
    Public Overloads Shared Function Main( _
        ByVal args() As String) As Integer

        Dim p As New ManagementPath( _
            "Win32_Service.Name=""Alerter""")
        Dim o As New ManagementObject(p)

        'Now it can be used 
        Console.WriteLine(o("Name"))

        Return 0
    End Function
End Class

注釈

.NET Framework のセキュリティ

直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。

適用対象

ManagementObject(String)

ソース:
ManagementObject.cs
ソース:
ManagementObject.cs
ソース:
ManagementObject.cs

指定した WMI (Windows Management Instrumentation) オブジェクト パスの ManagementObject クラスの新しいインスタンスを初期化します。 パスは、文字列として指定します。

public:
 ManagementObject(System::String ^ path);
public ManagementObject (string path);
new System.Management.ManagementObject : string -> System.Management.ManagementObject
Public Sub New (path As String)

パラメーター

path
String

WMI パス。

次の例では、 クラスの新しいインスタンスを ManagementObject 初期化します。

using System;
using System.Management;

class Sample
{
    public static int Main(string[] args)
    {
        ManagementObject o =
            new ManagementObject("Win32_Service.Name='Alerter'");

        //or with a full path :

        ManagementObject mObj =
            new ManagementObject(
            "\\\\MyServer\\root\\MyApp:MyClass.Key='abc'");

        return 0;
    }
}
Imports System.Management

Class Sample_ManagementClass
    Public Overloads Shared Function Main( _
        ByVal args() As String) As Integer

        Dim o As New ManagementObject( _
    "Win32_Service.Name=""Alerter""")

        ' or with a full path :

        Dim mObj As New ManagementObject( _
            "\\\\MyServer\\root\\MyApp:MyClass.Key=""abc""")

        Return 0
    End Function
End Class

注釈

指定したパスが相対パスのみの場合 (サーバーまたは名前空間が指定されていません)、既定のパスはローカル コンピューターであり、既定の名前空間は DefaultPath パス (既定では root\cimv2) です。 ユーザーが完全パスを指定した場合、既定の設定がオーバーライドされます。

.NET Framework のセキュリティ

直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。

適用対象

ManagementObject(ManagementPath, ObjectGetOptions)

ソース:
ManagementObject.cs
ソース:
ManagementObject.cs
ソース:
ManagementObject.cs

指定した追加のオプションを含む、指定した WMI パスにバインドする ManagementObject クラスの新しいインスタンスを初期化します。

public:
 ManagementObject(System::Management::ManagementPath ^ path, System::Management::ObjectGetOptions ^ options);
public ManagementObject (System.Management.ManagementPath path, System.Management.ObjectGetOptions options);
new System.Management.ManagementObject : System.Management.ManagementPath * System.Management.ObjectGetOptions -> System.Management.ManagementObject
Public Sub New (path As ManagementPath, options As ObjectGetOptions)

パラメーター

path
ManagementPath

WMI パスを格納している ManagementPath

options
ObjectGetOptions

WMI オブジェクトにバインドするための追加のオプションを格納している ObjectGetOptions。 既定のオプションを使用する場合、このパラメーターは null にすることができます。

次の例では、特定の WMI パスに ManagementObject バインドされている クラスの新しいインスタンスを初期化します。

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;
    }
}
Imports System.Management

Class Sample_ManagementClass
    Public Overloads Shared Function Main( _
        ByVal args() As String) As Integer

        Dim p As New ManagementPath("Win32_Service")

        ' Set options for no context info
        ' but requests amended qualifiers 
        ' to be contained in the object
        Dim opt As New ObjectGetOptions( _
            Nothing, TimeSpan.MaxValue, True)

        Dim c As New ManagementClass(p, opt)

        Console.WriteLine(c.Qualifiers("Description").Value)

        Return 0
    End Function
End Class

注釈

.NET Framework のセキュリティ

直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。

適用対象

ManagementObject(SerializationInfo, StreamingContext)

ソース:
ManagementObject.cs
ソース:
ManagementObject.cs
ソース:
ManagementObject.cs

注意事項

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

ManagementObject クラスのシリアル化可能な新しいインスタンスを初期化します。

protected:
 ManagementObject(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
public:
 ManagementObject(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected ManagementObject (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected ManagementObject (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
public ManagementObject (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Management.ManagementObject : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Management.ManagementObject
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Management.ManagementObject : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Management.ManagementObject
Protected Sub New (info As SerializationInfo, context As StreamingContext)
Public Sub New (info As SerializationInfo, context As StreamingContext)

パラメーター

info
SerializationInfo

データの読み込み先となる SerializationInfo

context
StreamingContext

このシリアル化のシリアル化先 (StreamingContext を参照)。

属性

注釈

.NET Framework のセキュリティ

直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。

適用対象

ManagementObject(String, ObjectGetOptions)

ソース:
ManagementObject.cs
ソース:
ManagementObject.cs
ソース:
ManagementObject.cs

指定した追加のオプションを含む、指定した WMI パスにバインドする ManagementObject クラスの新しいインスタンスを初期化します。 このバリアントでは、パスは文字列として指定できます。

public:
 ManagementObject(System::String ^ path, System::Management::ObjectGetOptions ^ options);
public ManagementObject (string path, System.Management.ObjectGetOptions options);
new System.Management.ManagementObject : string * System.Management.ObjectGetOptions -> System.Management.ManagementObject
Public Sub New (path As String, options As ObjectGetOptions)

パラメーター

path
String

オブジェクトへの WMI パス。

options
ObjectGetOptions

指定した WMI オブジェクトを取得するためのオプションを表す ObjectGetOptions

次の例では、 クラスの新しいインスタンスを ManagementObject 初期化します。

using System;
using System.Management;

class Sample
{
    public static int Main(string[] args)
    {
        // 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);

        ManagementObject o =
            new ManagementObject(
            "Win32_Service", opt);

        Console.WriteLine(o.GetQualifierValue("Description"));

        return 0;
    }
}
Imports System.Management

Class Sample_ManagementClass
    Public Overloads Shared Function Main( _
        ByVal args() As String) As Integer

        ' Set options for no context info, 
        ' but requests amended qualifiers
        ' to be contained in the object
        Dim opt As New ObjectGetOptions( _
            Nothing, System.TimeSpan.MaxValue, True)

        Dim o As New ManagementObject( _
            "Win32_Service", opt)

        Console.WriteLine(o.GetQualifierValue("Description"))

        Return 0
    End Function
End Class

注釈

.NET Framework のセキュリティ

直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。

適用対象

ManagementObject(ManagementScope, ManagementPath, ObjectGetOptions)

ソース:
ManagementObject.cs
ソース:
ManagementObject.cs
ソース:
ManagementObject.cs

指定したオプションを含む、指定した WMI パスにバインドする ManagementObject クラスの新しいインスタンスを初期化します。

public:
 ManagementObject(System::Management::ManagementScope ^ scope, System::Management::ManagementPath ^ path, System::Management::ObjectGetOptions ^ options);
public ManagementObject (System.Management.ManagementScope scope, System.Management.ManagementPath path, System.Management.ObjectGetOptions options);
new System.Management.ManagementObject : System.Management.ManagementScope * System.Management.ManagementPath * System.Management.ObjectGetOptions -> System.Management.ManagementObject
Public Sub New (scope As ManagementScope, path As ManagementPath, options As ObjectGetOptions)

パラメーター

scope
ManagementScope

WMI オブジェクトが存在するスコープを表す ManagementScope。 このバージョンでは、スコープは WMI 名前空間だけに設定できます。

path
ManagementPath

管理可能オブジェクトへの WMI パスを表す ManagementPath

options
ObjectGetOptions

オブジェクトを取得するための追加のオプションを指定する ObjectGetOptions

次の例では、特定の WMI パスに ManagementObject バインドされている クラスの新しいインスタンスを初期化します。

using System;
using System.Management;

class Sample
{
    public static int Main(string[] args)
    {
        ManagementScope s = new ManagementScope(
            "\\\\MyMachine\\root\\cimv2");
        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, TimeSpan.MaxValue, true);

        ManagementObject o = new ManagementObject(s, p, opt);

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

        return 0;
    }
}
Imports System.Management

Class Sample_ManagementClass
    Public Overloads Shared Function Main( _
        ByVal args() As String) As Integer

        Dim s As New ManagementScope( _
            "\\MyMachine\root\cimv2")
        Dim p As New ManagementPath( _
            "Win32_Service")

        ' Set options for no context info,
        ' but requests amended qualifiers 
        ' to be contained in the object
        Dim opt As ObjectGetOptions
        opt = New ObjectGetOptions( _
                Nothing, TimeSpan.MaxValue, True)

        Dim o As ManagementObject
        o = New ManagementObject(s, p, opt)

        Console.WriteLine(o.Qualifiers("Description").Value)

        Return 0
    End Function
End Class

注釈

WMI パスは相対パスまたは完全パスである可能性があるため、スコープと指定されたパスの間で競合が発生する可能性があります。 ただし、スコープが指定され、相対 WMI パスが指定されている場合、競合はありません。 考えられる競合の一部を次に示します。

スコープが指定されておらず、相対 WMI パスが指定されている場合、スコープは既定でローカル コンピューターの DefaultPathに設定されます。

スコープが指定されておらず、完全な WMI パスが指定されている場合、スコープは完全パスのスコープ部分から推論されます。 たとえば、完全な WMI パス: \\MyMachine\root\MyNamespace:MyClass.Name='abc' はスコープ '\\MyMachine\root\MyNamespace' の WMI オブジェクト 'MyClass.Name='abc' を表します。

スコープが指定され、完全な WMI パスが指定されている場合、スコープは完全パスのスコープ部分をオーバーライドします。 たとえば、スコープ \\MyMachine\root\MyScope が指定されていて、次の完全なパスが指定されている場合: \\MyMachine\root\MyNamespace:MyClass.Name='abc' は、次 object: \\MyMachine\root\MyScope:MyClass.Name= 'abc' のように検索します (完全パスのスコープ部分は無視されます)。

.NET Framework のセキュリティ

直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。

適用対象

ManagementObject(String, String, ObjectGetOptions)

ソース:
ManagementObject.cs
ソース:
ManagementObject.cs
ソース:
ManagementObject.cs

指定したオプションを含む、指定した WMI パスにバインドする ManagementObject クラスの新しいインスタンスを初期化します。 スコープとパスは、文字列として指定します。

public:
 ManagementObject(System::String ^ scopeString, System::String ^ pathString, System::Management::ObjectGetOptions ^ options);
public ManagementObject (string scopeString, string pathString, System.Management.ObjectGetOptions options);
new System.Management.ManagementObject : string * string * System.Management.ObjectGetOptions -> System.Management.ManagementObject
Public Sub New (scopeString As String, pathString As String, options As ObjectGetOptions)

パラメーター

scopeString
String

WMI オブジェクトのスコープ。

pathString
String

WMI オブジェクト パス。

options
ObjectGetOptions

WMI オブジェクトを取得するための追加のオプションを表す ObjectGetOptions

次の例では、特定の WMI パスとオプションを使用して ManagementObject 、 クラスの新しいインスタンスを初期化します。

using System;
using System.Management;

class Sample
{
    public static int Main(string[] args)
    {
        ObjectGetOptions opt =
            new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
        ManagementObject o =
            new ManagementObject(
            "root\\MyNamespace", "MyClass", opt);

        return 0;
    }
}
Imports System.Management

Class Sample_ManagementClass
    Public Overloads Shared Function Main( _
        ByVal args() As String) As Integer

        Dim opt As New ObjectGetOptions( _
            Nothing, System.TimeSpan.MaxValue, True)
        Dim o As New ManagementObject( _
            "root\MyNamespace", "MyClass", opt)

        Return 0
    End Function
End Class

注釈

詳細については、同等のオーバーロードを参照してください。

.NET Framework のセキュリティ

直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。

適用対象