ManagementObject.GetRelated 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會得到一組與該物件相關的物件(關聯器)。
多載
| 名稱 | Description |
|---|---|
| GetRelated() |
會得到一組與該物件相關的物件(關聯器)。 |
| GetRelated(ManagementOperationObserver) |
非同步取得與該物件相關的物件集合(關聯器)。 此通話會立即回傳,當結果出來時會呼叫代表。 |
| GetRelated(String) |
會得到一組與該物件相關的物件(關聯器)。 |
| GetRelated(ManagementOperationObserver, String) |
會得到一組與該物件相關的物件(關聯器)。 |
| GetRelated(String, String, String, String, String, String, Boolean, EnumerationOptions) |
會得到一組與該物件相關的物件(關聯器)。 |
| GetRelated(ManagementOperationObserver, String, String, String, String, String, String, Boolean, EnumerationOptions) |
會得到一組與該物件相關的物件(關聯器)。 |
GetRelated()
會得到一組與該物件相關的物件(關聯器)。
public:
System::Management::ManagementObjectCollection ^ GetRelated();
public System.Management.ManagementObjectCollection GetRelated();
member this.GetRelated : unit -> System.Management.ManagementObjectCollection
Public Function GetRelated () As ManagementObjectCollection
傳回
包含相關物件的 A ManagementObjectCollection 。
範例
以下範例呼叫 GetRelated 該方法,取得與該類別實例 ManagementObject 相關的物件集合。
using System;
using System.Management;
public class Sample
{
public static void Main(string[] args)
{
ManagementObject o =
new ManagementObject("Win32_Service='Alerter'");
foreach(ManagementObject b in o.GetRelated())
Console.WriteLine(
"Object related to Alerter service : {0}",
b.ClassPath);
}
}
Imports System.Management
Class Sample_ManagementClass
Public Overloads Shared Function Main( _
ByVal args() As String) As Integer
Dim o As New ManagementObject( _
"Win32_Service=""Alerter""")
Dim b As ManagementObject
For Each b In o.GetRelated()
Console.WriteLine( _
"Object related to Alerter service : {0}", _
b.ClassPath)
Next b
Return 0
End Function
End Class
備註
此操作等同於 ASSOCIATORS OF 查詢,其中 ResultClass = relatedClass。
.NET Framework 安全性
完全信任當下的來電者。 此成員無法被部分受信任的程式碼使用。 欲了解更多資訊,請參閱 「部分受信任程式碼的函式庫使用」。
適用於
GetRelated(ManagementOperationObserver)
非同步取得與該物件相關的物件集合(關聯器)。 此通話會立即回傳,當結果出來時會呼叫代表。
public:
void GetRelated(System::Management::ManagementOperationObserver ^ watcher);
public void GetRelated(System.Management.ManagementOperationObserver watcher);
member this.GetRelated : System.Management.ManagementOperationObserver -> unit
Public Sub GetRelated (watcher As ManagementOperationObserver)
參數
- watcher
- ManagementOperationObserver
用來回傳結果的物件。
備註
.NET Framework 安全性
完全信任當下的來電者。 此成員無法被部分受信任的程式碼使用。 欲了解更多資訊,請參閱 「部分受信任程式碼的函式庫使用」。
適用於
GetRelated(String)
會得到一組與該物件相關的物件(關聯器)。
public:
System::Management::ManagementObjectCollection ^ GetRelated(System::String ^ relatedClass);
public System.Management.ManagementObjectCollection GetRelated(string relatedClass);
member this.GetRelated : string -> System.Management.ManagementObjectCollection
Public Function GetRelated (relatedClass As String) As ManagementObjectCollection
參數
- relatedClass
- String
一類相關物件。
傳回
包含相關物件的 A ManagementObjectCollection 。
範例
以下範例呼叫 GetRelated 該方法,取得與該類別實例 ManagementObject 相關的物件集合。
using System;
using System.Management;
public class Sample
{
public static void Main(string[] args)
{
ManagementObject o =
new ManagementObject("Win32_Service='Alerter'");
foreach (ManagementObject b in
o.GetRelated("Win32_Service"))
Console.WriteLine(
"Service related to the Alerter service {0} is {1}",
b["Name"], b["State"]);
}
}
Imports System.Management
Class Sample_ManagementClass
Public Overloads Shared Function Main( _
ByVal args() As String) As Integer
Dim o As New ManagementObject( _
"Win32_Service=""Alerter""")
Dim b As ManagementObject
For Each b In o.GetRelated("Win32_Service")
Console.WriteLine( _
"Service related to the Alerter service {0} is {1}", _
b("Name"), b("State"))
Next b
Return 0
End Function
End Class
備註
.NET Framework 安全性
完全信任當下的來電者。 此成員無法被部分受信任的程式碼使用。 欲了解更多資訊,請參閱 「部分受信任程式碼的函式庫使用」。
適用於
GetRelated(ManagementOperationObserver, String)
會得到一組與該物件相關的物件(關聯器)。
public:
void GetRelated(System::Management::ManagementOperationObserver ^ watcher, System::String ^ relatedClass);
public void GetRelated(System.Management.ManagementOperationObserver watcher, string relatedClass);
member this.GetRelated : System.Management.ManagementOperationObserver * string -> unit
Public Sub GetRelated (watcher As ManagementOperationObserver, relatedClass As String)
參數
- watcher
- ManagementOperationObserver
用來回傳結果的物件。
- relatedClass
- String
相關物件類別。
備註
此操作等同於 ASSOCIATORS OF 查詢,其中 ResultClass = relatedClass。
.NET Framework 安全性
完全信任當下的來電者。 此成員無法被部分受信任的程式碼使用。 欲了解更多資訊,請參閱 「部分受信任程式碼的函式庫使用」。
適用於
GetRelated(String, String, String, String, String, String, Boolean, EnumerationOptions)
會得到一組與該物件相關的物件(關聯器)。
public:
System::Management::ManagementObjectCollection ^ GetRelated(System::String ^ relatedClass, System::String ^ relationshipClass, System::String ^ relationshipQualifier, System::String ^ relatedQualifier, System::String ^ relatedRole, System::String ^ thisRole, bool classDefinitionsOnly, System::Management::EnumerationOptions ^ options);
public System.Management.ManagementObjectCollection GetRelated(string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, string thisRole, bool classDefinitionsOnly, System.Management.EnumerationOptions options);
member this.GetRelated : string * string * string * string * string * string * bool * System.Management.EnumerationOptions -> System.Management.ManagementObjectCollection
Public Function GetRelated (relatedClass As String, relationshipClass As String, relationshipQualifier As String, relatedQualifier As String, relatedRole As String, thisRole As String, classDefinitionsOnly As Boolean, options As EnumerationOptions) As ManagementObjectCollection
參數
- relatedClass
- String
相關物件的類別。
- relationshipClass
- String
感興趣的關係類別。
- relationshipQualifier
- String
條件要求必須在關係類別中具備。
- relatedQualifier
- String
資格考證必須具備相關類別。
- relatedRole
- String
相關階級在關係中扮演的角色。
- thisRole
- String
這個階級在關係中扮演的角色。
- classDefinitionsOnly
- Boolean
當此方法回傳時,僅包含與查詢相符實例的類別定義。
- options
- EnumerationOptions
關於如何執行查詢的延伸選項。
傳回
包含相關物件的 A ManagementObjectCollection 。
備註
此操作等同於 ASSOCIATORS OF 查詢,其中 ResultClass = relatedClass。
.NET Framework 安全性
完全信任當下的來電者。 此成員無法被部分受信任的程式碼使用。 欲了解更多資訊,請參閱 「部分受信任程式碼的函式庫使用」。
適用於
GetRelated(ManagementOperationObserver, String, String, String, String, String, String, Boolean, EnumerationOptions)
會得到一組與該物件相關的物件(關聯器)。
public:
void GetRelated(System::Management::ManagementOperationObserver ^ watcher, System::String ^ relatedClass, System::String ^ relationshipClass, System::String ^ relationshipQualifier, System::String ^ relatedQualifier, System::String ^ relatedRole, System::String ^ thisRole, bool classDefinitionsOnly, System::Management::EnumerationOptions ^ options);
public void GetRelated(System.Management.ManagementOperationObserver watcher, string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, string thisRole, bool classDefinitionsOnly, System.Management.EnumerationOptions options);
member this.GetRelated : System.Management.ManagementOperationObserver * string * string * string * string * string * string * bool * System.Management.EnumerationOptions -> unit
Public Sub GetRelated (watcher As ManagementOperationObserver, relatedClass As String, relationshipClass As String, relationshipQualifier As String, relatedQualifier As String, relatedRole As String, thisRole As String, classDefinitionsOnly As Boolean, options As EnumerationOptions)
參數
- watcher
- ManagementOperationObserver
用來回傳結果的物件。
- relatedClass
- String
相關物件的類別。
- relationshipClass
- String
感興趣的關係類別。
- relationshipQualifier
- String
條件要求必須在關係類別中具備。
- relatedQualifier
- String
資格考證必須具備相關類別。
- relatedRole
- String
相關階級在關係中扮演的角色。
- thisRole
- String
這個階級在關係中扮演的角色。
- classDefinitionsOnly
- Boolean
只回傳符合查詢的實例的類別定義。
- options
- EnumerationOptions
關於如何執行查詢的延伸選項。
備註
此操作等同於 ASSOCIATORS OF 查詢,其中 ResultClass = relatedClass。
.NET Framework 安全性
完全信任當下的來電者。 此成員無法被部分受信任的程式碼使用。 欲了解更多資訊,請參閱 「部分受信任程式碼的函式庫使用」。