ManagementObject コンストラクター

定義

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

オーバーロード

名前 説明
ManagementObject()

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

ManagementObject(ManagementPath)

指定した WMI オブジェクト パスの ManagementObject クラスの新しいインスタンスを初期化します。 パスは ManagementPathとして提供されます。

ManagementObject(String)

指定した WMI オブジェクト パスの 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.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
ソース:
ManagementObject.cs

指定した WMI オブジェクト パスの 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
ソース:
ManagementObject.cs

指定した WMI オブジェクト パスの 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
ソース:
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
ソース:
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);
[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);
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}")>]
new System.Management.ManagementObject : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Management.ManagementObject
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
ソース:
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
ソース:
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
ソース:
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 のセキュリティ

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

適用対象