C#中通过WMI的Win32_DiskDrive对象获取磁盘驱动器信息简介

1、简介

在WMI中,通过Win32_DiskDrive对象可以获取磁盘驱动器的相关信息:

ManagementClass mc = new ManagementClass("Win32_DiskDrive");

ManagementObjectCollection moc = mc.GetInstances();

foreach (ManagementObject mo in moc)

{

propertyInfo = mo.Properties[PropertyName].Value.ToString();

}

2、属性名

Win32_DiskDrive对象的属性名如下:

Availability

BytesPerSector

Capabilities

CapabilityDescriptions

Caption

CompressionMethod

ConfigManagerErrorCode

ConfigManagerUserConfig

CreationClassName

DefaultBlockSize

Description

DeviceID

ErrorCleared

ErrorDescription

ErrorMethodology

FirmwareRevision

Index

InstallDate

InterfaceType

LastErrorCode

Manufacturer

MaxBlockSize

MaxMediaSize

MediaLoaded

MediaType

MinBlockSize

Model

Name

NeedsCleaning

NumberOfMediaSupported

Partitions

PNPDeviceID

PowerManagementCapabilities

PowerManagementSupported

SCSIBus

SCSILogicalUnit

SCSIPort

SCSITargetId

SectorsPerTrack

SerialNumber

Signature

Size

Status

StatusInfo

SystemCreationClassName

SystemName

TotalCylinders

TotalHeads

TotalSectors

TotalTracks

TracksPerCylinder