次の方法で共有


ManagementObject コンストラクタ (ManagementScope, ManagementPath, ObjectGetOptions)

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

名前空間: System.Management
アセンブリ: System.Management (system.management.dll 内)

構文

'宣言
Public Sub New ( _
    scope As ManagementScope, _
    path As ManagementPath, _
    options As ObjectGetOptions _
)
'使用
Dim scope As ManagementScope
Dim path As ManagementPath
Dim options As ObjectGetOptions

Dim instance As New ManagementObject(scope, path, options)
public ManagementObject (
    ManagementScope scope,
    ManagementPath path,
    ObjectGetOptions options
)
public:
ManagementObject (
    ManagementScope^ scope, 
    ManagementPath^ path, 
    ObjectGetOptions^ options
)
public ManagementObject (
    ManagementScope scope, 
    ManagementPath path, 
    ObjectGetOptions options
)
public function ManagementObject (
    scope : ManagementScope, 
    path : ManagementPath, 
    options : ObjectGetOptions
)

パラメータ

  • scope
    WMI オブジェクトが存在するスコープを表す ManagementScope。このバージョンでは、スコープは WMI 名前空間だけに設定できます。
  • path
    管理可能オブジェクトへの WMI パスを表す ManagementPath
  • options
    オブジェクトを取得するための追加のオプションを指定する ObjectGetOptions

解説

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 のセキュリティ

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

使用例

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

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

.NET Framework のセキュリティ

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

プラットフォーム

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

開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

参照

関連項目

ManagementObject クラス
ManagementObject メンバ
System.Management 名前空間