MethodData.OutParameters 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得方法的輸出參數。 每個參數都是描述為物件中的屬性。 如果參數同時是輸入和輸出參數,則會出現在 InParameters 和 OutParameters 屬性中。
public:
property System::Management::ManagementBaseObject ^ OutParameters { System::Management::ManagementBaseObject ^ get(); };
public System.Management.ManagementBaseObject OutParameters { get; }
member this.OutParameters : System.Management.ManagementBaseObject
Public ReadOnly Property OutParameters As ManagementBaseObject
屬性值
傳回 ManagementBaseObject,內含方法的輸出參數。
範例
下列範例會使用 MethodData 類別列出 Win32_Process.Create 方法的相關信息。 如需 Win32_Process 類別的詳細資訊,請參閱 Windows Management Instrumentation 檔。
using System;
using System.Management;
public class Sample
{
public static void Main()
{
// Get the WMI class
ManagementClass processClass =
new ManagementClass("Win32_Process");
processClass.Options.UseAmendedQualifiers = true;
// Get the methods in the class
MethodDataCollection methods =
processClass.Methods;
// display the method names
Console.WriteLine("Method Name: ");
foreach (MethodData method in methods)
{
if(method.Name.Equals("Create"))
{
Console.WriteLine(method.Name);
Console.WriteLine("Description: " +
method.Qualifiers["Description"].Value);
Console.WriteLine();
Console.WriteLine("In-parameters: ");
foreach(PropertyData i in
method.InParameters.Properties)
{
Console.WriteLine(i.Name);
}
Console.WriteLine();
Console.WriteLine("Out-parameters: ");
foreach(PropertyData o in
method.OutParameters.Properties)
{
Console.WriteLine(o.Name);
}
Console.WriteLine();
Console.WriteLine("Qualifiers: ");
foreach(QualifierData q in
method.Qualifiers)
{
Console.WriteLine(q.Name);
}
Console.WriteLine();
}
}
}
}
Imports System.Management
Public Class Sample
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
' Get the WMI class
Dim processClass As ManagementClass = _
New ManagementClass("Win32_Process")
processClass.Options.UseAmendedQualifiers = True
' Get the methods in the class
Dim methods As MethodDataCollection = _
processClass.Methods
' display the method names
Console.WriteLine("Method Name: ")
For Each method As MethodData In methods
If (method.Name.Equals("Create")) Then
Console.WriteLine(method.Name)
Console.WriteLine("Description: " & _
method.Qualifiers("Description").Value)
Console.WriteLine()
Console.WriteLine("In-parameters: ")
For Each i As PropertyData In _
method.InParameters.Properties
Console.WriteLine(i.Name)
Next
Console.WriteLine()
Console.WriteLine("Out-parameters: ")
For Each o As PropertyData In _
method.OutParameters.Properties
Console.WriteLine(o.Name)
Next
Console.WriteLine()
Console.WriteLine("Qualifiers: ")
For Each q As QualifierData In _
method.Qualifiers
Console.WriteLine(q.Name)
Next
Console.WriteLine()
End If
Next
End Function 'Main
End Class
備註
這個物件中的每個參數都應該有標識元限定符,以識別方法呼叫中的參數順序。
ReturnValue 屬性是 屬性所OutParameters傳回的特殊屬性ManagementBaseObject,並保留 方法的傳回值。
屬性值
, ManagementBaseObject 包含方法的所有輸出參數。
.NET Framework 安全性
完全信任立即呼叫者。 這個成員無法供部分信任的程式碼使用。 如需詳細資訊,請參閱 使用部分信任程式代碼的連結庫。