不知道这个的输出有没有你要的SNConst strComputer As String = "." Dim strClass As String Dim wbemServices As Object Dim wbemObjectSet As Object Dim wbemObject As Object Dim p As Object Set wbemServices = GetObject("winmgmts:\\" & strComputer) Set wbemObjectSet = wbemServices.InstancesOf("CIM_DiskDrive") For Each wbemObject In wbemObjectSet Debug.Print "-------Properties---" For Each p In wbemObject.Properties_ Debug.Print p.Name; ":"; ConvPVtoStr(p.Value) Next Debug.Print "-------System Properties---" For Each p In wbemObject.SystemProperties_ Debug.Print p.Name; ":"; ConvPVtoStr(p.Value) Next Next-------Properties--- Availability: BytesPerSector:512 Capabilities:3,4 CapabilityDescriptions: Caption:FUJITSU MJA2250BH G2 CompressionMethod: ConfigManagerErrorCode:0 ConfigManagerUserConfig:False CreationClassName:Win32_DiskDrive DefaultBlockSize: Description:磁盘驱动器 DeviceID:\\.\PHYSICALDRIVE0 ErrorCleared: ErrorDescription: ErrorMethodology: Index:0 InstallDate: InterfaceType:IDE LastErrorCode: Manufacturer:(标准磁盘驱动器) MaxBlockSize: MaxMediaSize: MediaLoaded:True MediaType:Fixed hard disk media MinBlockSize: Model:FUJITSU MJA2250BH G2 Name:\\.\PHYSICALDRIVE0 NeedsCleaning: NumberOfMediaSupported: Partitions:4 PNPDeviceID:IDE\DISKFUJITSU_MJA2250BH_G2____________________0084001C\5&4AEFDA8&0&0.0.0 PowerManagementCapabilities: PowerManagementSupported: SCSIBus:0 SCSILogicalUnit:0 SCSIPort:0 SCSITargetId:0 SectorsPerTrack:63 Signature:1064714101 Size:250056737280 Status:OK StatusInfo: SystemCreationClassName:Win32_ComputerSystem SystemName:BJZJ-YANGWEI TotalCylinders:30401 TotalHeads:255 TotalSectors:488392065 TotalTracks:7752255 TracksPerCylinder:255 -------System Properties--- __PATH:\\BJZJ-YANGWEI\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0" __NAMESPACE:root\cimv2 __SERVER:BJZJ-YANGWEI __DERIVATION:CIM_DiskDrive,CIM_MediaAccessDevice,CIM_LogicalDevice,CIM_LogicalElement,CIM_ManagedSystemElement __PROPERTY_COUNT:49 __RELPATH:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0" __DYNASTY:CIM_ManagedSystemElement __SUPERCLASS:CIM_DiskDrive __CLASS:Win32_DiskDrive __GENUS:2
有没有不用SMART接口获取硬盘序列号的代码?
Dim strClass As String
Dim wbemServices As Object
Dim wbemObjectSet As Object
Dim wbemObject As Object
Dim p As Object
Set wbemServices = GetObject("winmgmts:\\" & strComputer)
Set wbemObjectSet = wbemServices.InstancesOf("CIM_DiskDrive")
For Each wbemObject In wbemObjectSet
Debug.Print "-------Properties---"
For Each p In wbemObject.Properties_
Debug.Print p.Name; ":"; ConvPVtoStr(p.Value)
Next
Debug.Print "-------System Properties---"
For Each p In wbemObject.SystemProperties_
Debug.Print p.Name; ":"; ConvPVtoStr(p.Value)
Next
Next-------Properties---
Availability:
BytesPerSector:512
Capabilities:3,4
CapabilityDescriptions:
Caption:FUJITSU MJA2250BH G2
CompressionMethod:
ConfigManagerErrorCode:0
ConfigManagerUserConfig:False
CreationClassName:Win32_DiskDrive
DefaultBlockSize:
Description:磁盘驱动器
DeviceID:\\.\PHYSICALDRIVE0
ErrorCleared:
ErrorDescription:
ErrorMethodology:
Index:0
InstallDate:
InterfaceType:IDE
LastErrorCode:
Manufacturer:(标准磁盘驱动器)
MaxBlockSize:
MaxMediaSize:
MediaLoaded:True
MediaType:Fixed hard disk media
MinBlockSize:
Model:FUJITSU MJA2250BH G2
Name:\\.\PHYSICALDRIVE0
NeedsCleaning:
NumberOfMediaSupported:
Partitions:4
PNPDeviceID:IDE\DISKFUJITSU_MJA2250BH_G2____________________0084001C\5&4AEFDA8&0&0.0.0
PowerManagementCapabilities:
PowerManagementSupported:
SCSIBus:0
SCSILogicalUnit:0
SCSIPort:0
SCSITargetId:0
SectorsPerTrack:63
Signature:1064714101
Size:250056737280
Status:OK
StatusInfo:
SystemCreationClassName:Win32_ComputerSystem
SystemName:BJZJ-YANGWEI
TotalCylinders:30401
TotalHeads:255
TotalSectors:488392065
TotalTracks:7752255
TracksPerCylinder:255
-------System Properties---
__PATH:\\BJZJ-YANGWEI\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"
__NAMESPACE:root\cimv2
__SERVER:BJZJ-YANGWEI
__DERIVATION:CIM_DiskDrive,CIM_MediaAccessDevice,CIM_LogicalDevice,CIM_LogicalElement,CIM_ManagedSystemElement
__PROPERTY_COUNT:49
__RELPATH:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"
__DYNASTY:CIM_ManagedSystemElement
__SUPERCLASS:CIM_DiskDrive
__CLASS:Win32_DiskDrive
__GENUS:2
你说错了,网上N多程序都可以返回SATA硬盘的,我硬盘就是SATA一样返回得到序列号