用WMI类,比如:using System; using System.Management; using ROOT.CIMV2.Win32;public class App { public static void Main() { // Enumerate instances of the Win32_process. // Print the Name property of the instance. foreach(Process ps in Process.GetInstances()) { Console.WriteLine(ps.Name); } // Initialize the instance of LogicalDisk with // the WMI instance pointing to logical drive d:. LogicalDisk dskD = new LogicalDisk(new ManagementPath( "win32_LogicalDisk.DeviceId=\"d:\"")); Console.WriteLine(dskD.Caption); } }
using System.Management;
using ROOT.CIMV2.Win32;public class App
{
public static void Main()
{
// Enumerate instances of the Win32_process.
// Print the Name property of the instance.
foreach(Process ps in Process.GetInstances())
{
Console.WriteLine(ps.Name);
} // Initialize the instance of LogicalDisk with
// the WMI instance pointing to logical drive d:.
LogicalDisk dskD = new LogicalDisk(new ManagementPath(
"win32_LogicalDisk.DeviceId=\"d:\""));
Console.WriteLine(dskD.Caption);
}
}