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 支持的唯一格式是 托管对象格式 (MOF) 。 将来,将支持其他格式,例如可扩展标记语言 (XML) 。

.NET Framework 安全性

对直接调用方的完全信任。 此成员不能由部分信任的代码使用。 有关详细信息,请参阅 从部分受信任的代码使用库

适用于