次の方法で共有


ManagementClass.GetInstances メソッド (EnumerationOptions)

指定したオプションを使用して、クラスのすべてのインスタンスのコレクションを返します。

Overloads Public Function GetInstances( _
   ByVal options As EnumerationOptions _) As ManagementObjectCollection
[C#]
public ManagementObjectCollection GetInstances(EnumerationOptionsoptions);
[C++]
public: ManagementObjectCollection* GetInstances(EnumerationOptions* options);
[JScript]
public function GetInstances(
   options : EnumerationOptions) : ManagementObjectCollection;

パラメータ

  • options
    追加の操作オプション。

戻り値

指定したオプションに従って、クラスのインスタンスを表す ManagementObject オブジェクトのコレクション。

使用例

 
EnumerationOptions opt = new EnumerationOptions();
//Will enumerate instances of the given class and any subclasses.
o.enumerateDeep = true;
ManagementClass c = new ManagementClass("CIM_Service");
foreach (ManagementObject o in c.GetInstances(opt))
    Console.WriteLine(o["Name"]);
   
[Visual Basic] 
Dim opt As New EnumerationOptions()
'Will enumerate instances of the given class and any subclasses.
o.enumerateDeep = True
Dim c As New ManagementClass("CIM_Service")
Dim o As ManagementObject
For Each o In c.GetInstances(opt)
    Console.WriteLine(o["Name"])
Next o
   

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

ManagementClass クラス | ManagementClass メンバ | System.Management 名前空間 | ManagementClass.GetInstances オーバーロードの一覧