ManagementBaseObject.GetText(TextFormat) 方法

定義

以指定格式傳回物件的文字表示。

public:
 System::String ^ GetText(System::Management::TextFormat format);
public string GetText (System.Management.TextFormat format);
member this.GetText : System.Management.TextFormat -> string
Public Function GetText (format As TextFormat) As String

參數

format
TextFormat

所要求的文字格式。

傳回

String

指定格式的物件文字表示。

範例

下列範例會使用 GetText 方法顯示 Win32_Process 類別的 MOF 程式碼。 如需 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;

        Console.WriteLine(
            processClass.GetText(
            TextFormat.Mof));
    }
}
Imports System.Management


Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        Dim processClass As New ManagementClass( _
            "Win32_Process")
        processClass.Options.UseAmendedQualifiers = True

        Console.WriteLine( _
            processClass.GetText( _
            TextFormat.Mof))

    End Function
End Class

備註

目前,WMI 支援的唯一格式是 Managed Object Format (MOF) 。 未來將支援其他格式,例如可延伸標記語言 (XML) 。

.NET Framework 安全性

完全信任立即呼叫者。 這個成員無法供部分信任的程式碼使用。 如需詳細資訊,請參閱 使用部分信任程式碼的程式庫

適用於