日期:2014-05-16 浏览次数:20995 次
SelectQuery diskPartition = new SelectQuery("Win32_DiskPartition");
SelectQuery logicalDisk = new SelectQuery("Win32_LogicalDisk");
ManagementObjectSearcher serch1 = new ManagementObjectSearcher(diskPartition);
ManagementObjectSearcher serch2 = new ManagementObjectSearcher(logicalDisk);
foreach (ManagementObject disk in serch1.Get()) {
string id = disk["DiskIndex"].ToString() + disk["Index"].ToString() + disk["Size"].ToString();
foreach (ManagementObject p in serch2.Get())
{
if (disk["Name"] == p["Name"]) { //此处不知如何进行关联
Debug.WriteLine(p["Size"]);
}
}
}
ComputerName = "."
Set wmiServices = GetObject ( _
"winmgmts:{impersonationLevel=Impersonate}!//" _
& ComputerName)
' Get physical disk drive
Set wmiDiskDrives = wmiServices.ExecQuery ( _
"SELECT Caption, DeviceID FROM Win32_DiskDrive")
For Each wmiDiskDrive In wmiDiskDrives
WScript.Echo "Disk drive Caption: " _
& wmiDiskDrive.Caption _
& VbNewLine & "DeviceID: " _
& " (" & wmiDiskDrive.DeviceID & ")"
'Use the disk drive device id to
' find associated partition
&