ManagementBaseObject.GetText(TextFormat) 方法

定义

以指定的格式返回对象的文本化表示形式。Returns a textual representation of the object in the specified format.

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

请求的文本化格式。The requested textual format.

返回

采用指定格式的对象的文本化表示形式。The textual representation of the object in the specified format.

示例

下面的示例通过使用 GetText 方法显示Win32_Process类的 MOF 代码。The following example displays the MOF code for the Win32_Process class by using the GetText method. 有关Win32_Process类的详细信息,请参阅Windows Management Instrumentation文档。For more information about the Win32_Process class, see the Windows Management Instrumentation documentation.

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)。Currently, the only format that WMI supports is Managed Object Format (MOF). 以后将支持其他格式,如可扩展标记语言(XML)。In the future, other formats will be supported, such as Extensible Markup Language (XML).

.NET Framework 安全性.NET Framework Security

对直接调用方的完全信任。Full trust for the immediate caller. 部分信任的程式碼無法使用此成員。This member cannot be used by partially trusted code. 有关详细信息,请参阅从部分受信任的代码使用库For more information, see Using Libraries from Partially Trusted Code.

适用于