ManagementPath.ClassName 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定路徑的類別部分。
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
屬性值
傳回 String 值,內含路徑的類別部分。
範例
下列範例示範 類別如何 ManagementPath 剖析 WMI 對象的路徑。 範例中剖析的路徑是類別實例的路徑。
using System;
using System.Management;
public class Sample
{
public static void Main()
{
// Get the WMI class path
ManagementPath p =
new ManagementPath(
"\\\\ComputerName\\root" +
"\\cimv2:Win32_LogicalDisk.DeviceID=\"C:\"");
Console.WriteLine("IsClass: " +
p.IsClass);
// Should be False (because it is an instance)
Console.WriteLine("IsInstance: " +
p.IsInstance);
// Should be True
Console.WriteLine("ClassName: " +
p.ClassName);
// Should be "Win32_LogicalDisk"
Console.WriteLine("NamespacePath: " +
p.NamespacePath);
// Should be "ComputerName\cimv2"
Console.WriteLine("Server: " +
p.Server);
// Should be "ComputerName"
Console.WriteLine("Path: " +
p.Path);
// Should be "ComputerName\root\cimv2:
// Win32_LogicalDisk.DeviceId="C:""
Console.WriteLine("RelativePath: " +
p.RelativePath);
// Should be "Win32_LogicalDisk.DeviceID="C:""
}
}
Imports System.Management
Public Class Sample
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
' Get the WMI class path
Dim p As ManagementPath = _
New ManagementPath( _
"\\ComputerName\root" & _
"\cimv2:Win32_LogicalDisk.DeviceID=""C:""")
Console.WriteLine("IsClass: " & _
p.IsClass)
' Should be False (because it is an instance)
Console.WriteLine("IsInstance: " & _
p.IsInstance)
' Should be True
Console.WriteLine("ClassName: " & _
p.ClassName)
' Should be "Win32_LogicalDisk"
Console.WriteLine("NamespacePath: " & _
p.NamespacePath)
' Should be "ComputerName\cimv2"
Console.WriteLine("Server: " & _
p.Server)
' Should be "ComputerName"
Console.WriteLine("Path: " & _
p.Path)
' Should be "ComputerName\root\cimv2:
' Win32_LogicalDisk.DeviceId="C:""
Console.WriteLine("RelativePath: " & _
p.RelativePath)
' Should be "Win32_LogicalDisk.DeviceID="C:""
End Function
End Class
備註
屬性值
包含類別名稱的字串。
.NET Framework 安全性
完全信任立即呼叫者。 這個成員無法供部分信任的程式碼使用。 如需詳細資訊,請參閱 使用部分信任程式代碼的連結庫。