編輯

共用方式為


SelectQuery.ClassName Property

Definition

Gets or sets the class name to be selected from in the query.

public:
 property System::String ^ ClassName { System::String ^ get(); void set(System::String ^ value); };
public string ClassName { get; set; }
member this.ClassName : string with get, set
Public Property ClassName As String

Property Value

Returns a String value containing the name of the class in the query.

Examples

The following example initializes a SelectQuery by specifying a query and then changes the ClassName property.

using System;
using System.Management;

class Sample
{
    public static void Main(string[] args)
    {
        SelectQuery s =
            new SelectQuery("SELECT * FROM Win32_LogicalDisk");

        //output is : SELECT * FROM Win32_LogicalDisk
        Console.WriteLine(s.QueryString);

        s.ClassName = "Win32_Process";

        //output is : SELECT * FROM Win32_Process
        Console.WriteLine(s.QueryString);
    }
}
Imports System.Management


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

        Dim s As New SelectQuery( _
            "SELECT * FROM Win32_LogicalDisk")

        'output is : SELECT * FROM Win32_LogicalDisk
        Console.WriteLine(s.QueryString)

        s.ClassName = "Win32_Process"

        'output is : SELECT * FROM Win32_Process
        Console.WriteLine(s.QueryString)

    End Function
End Class

Remarks

Setting this property value overrides any previous value stored in the object. The query string is rebuilt to reflect the new class name.

A value for the ClassName property would replace the <className> item in a SELECT query of the form "SELECT * FROM <className> WHERE <condition>".

Property Value

A string representing the name of the class in the query.

.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.

Applies to