获得硬盘的物理序列号

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Private Const SMART_ENABLE_DISABLE_ATTRIBUTE_AUTOSAVE As Long = &HD2
Private Const SMART_SAVE_ATTRIBUTE_VALUES As Long = &HD3
Private Const SMART_EXECUTE_OFFLINE_IMMEDIATE As Long = &HD4 ' ATA4
Private Const DFP_SEND_DRIVE_COMMAND As Long = &H7C084
Private Const DFP_RECEIVE_DRIVE_DATA As Long = &H7C088
Private Type GETVERSIONOUTPARAMS
bVersion As Byte ' Binary driver version.
dwReserved(1) As Long ' Reserved for future expansion.
End Type
Private Const SMART_NO_ERROR As Long = 0 ' No error
Private Const SMART_IDE_ERROR As Long = 1 ' Error from IDE controller
Private Const SMART_INVALID_FLAG As Long = 2 ' Invalid command flag
Private Const SMART_INVALID_COMMAND As Long = 3 ' Invalid command byte
Private Const SMART_INVALID_BUFFER As Long = 4 ' Bad buffer (null, invalid addr..)
Private Const CAP_IDE_EXECUTE_SMART_FUNCTION As Long = 4 ' SMART commannds supported
Private Type IDEREGS
bFeaturesReg As Byte ' Used for specifying SMART "commands".
bWorstValue As Byte ' How bad has it ever been?
bRawValue(5) As Byte ' Un-normalized value
bReserved As Byte '
End Type
Private Type ATTRTHRESHOLD
End Type
Private Const IDE_ATAPI_ID As Long = &HA1 ' Returns ID sector for ATAPI.
Private Const IDE_ID_FUNCTION As Long = &HEC ' Returns ID sector for ATA.
dwReserved(3) As Long ' For future use.
End Type
Private Const CAP_IDE_ID_FUNCTION As Long = 1 ' ATA ID command supported
Private Const CAP_IDE_ATAPI_ID As Long = 2 ' ATAPI ID command supported
'============================================
'模块功能:取得硬盘的信息
'更新日期:2005/7/8
'调用方法:
' GetDiskVolume() 取得逻辑盘的序列号
' GetHardDiskInfo() 取得物理盘的型号或序列号
'============================================
Private Const IDE_EXECUTE_SMART_FUNCTION As Long = &HB0 ' Performs SMART cmd.
Private Const SMART_CYL_LOW As Long = &H4F
Private Const SMART_CYL_HI As Long = &HC2
irDriveRegs As IDEREGS ' Structure with drive register values.
bDriveNumber As Byte ' Physical drive number to send
' command to (0,1,2,3).
bSectorCountReg As Byte ' IDE sector count register
bSectorNumberReg As Byte ' IDE sector number register
bCylLowReg As Byte ' IDE low order cylinder value
Private Const SMART_INVALID_REGISTER As Long = 8 ' Some IDE Register not valid
Private Const SMART_NOT_SUPPORTED As Long = 9 ' Invalid cmd flag set
End Type
Private Const SMART_READ_ATTRIBUTE_VALUES As Long = &HD0 ' ATA4: Renamed
Private Const SMART_READ_ATTRIBUTE_THRESHOLDS As Long = &HD1 ' Obsoleted in ATA4!
Private Type DRIVERSTATUS
bDriverError As Byte ' Error code from driver,
bIDEStatus As Byte ' Contents of IDE Error register.
bReserved(1) As Byte ' Reserved for future expansion.
Private Const MAX_IDE_DRIVES As Long = 4 ' Max number of drives assuming primary/secondary, master/slave topology
Private Const READ_ATTRIBUTE_BUFFER_SIZE As Long = 512
bCylHighReg As Byte ' IDE high order cylinder value
bDriveHeadReg As Byte ' IDE drive/head register
bCommandReg As Byte ' Actual IDE command.
drvStatus As DRIVERSTATUS ' Driver status structure.
bBuffer(0) As Byte ' Buffer of arbitrary length in which to store the data read from the ' drive.
bRevision As Byte ' Binary driver revision.
bReserved As Byte ' Not used.
bIDEDeviceMap As Byte ' Bit map of IDE devices.
fCapabilities As Long ' Bit mask of driver capabilities.
bAttrID As Byte ' Identifies which attribute
bWarrantyThreshold As Byte ' Triggering value
bReserved(9) As Byte '
End Type
Private Const SMART_INVALID_DRIVE As Long = 5 ' Drive number not valid
Private Const SMART_INVALID_IOCTL As Long = 6 ' Invalid IOCTL
Private Const SMART_ERROR_NO_MEM As Long = 7 ' Could not lock user's buffer
Private Const IDENTIFY_BUFFER_SIZE As Long = 512
Private Const READ_THRESHOLD_BUFFER_SIZE As Long = 512
Private Const DFP_GET_VERSION As Long = &H74080
Private Const SMART_ENABLE_SMART_OPERATIONS As Long = &HD8
Private Const SMART_DISABLE_SMART_OPERATIONS As Long = &HD9
Private Const SMART_RETURN_SMART_STATUS As Long = &HDA
bReserved(2) As Byte ' Reserved for future expansion.
dwReserved(3) As Long ' For future use.
bBuffer(0) As Byte ' Input buffer.
bReserved As Byte ' reserved for future use. Must be zero.
End Type
Private Type S As Long ' Buffer size in bytes
Private Type IDSECTOR
wGenConfig As Integer
wNumCyls As Integer
wReserved As Integer
Private Const SMART_NO_IDE_DEVICE As Long = 10 ' Cmd issued to device not present
Private Type SENDCMDOUTPARAMS
cBufferSize As Long ' Size of bBuffer in bytes
Private Type DRIVEATTRIBUTE
bAttrID As Byte ' Identifies which attribute
wStatusFlags As Integer ' see bit definitions below
bAttrValue As Byte ' Current normalized value
相关文档
最新文档