又来一帖:获得硬盘序列号问题?

ww_cain 2006-04-14 09:40:46
vb里可以,但是打包成组件后asp里却得不到值呢(组件已注册成功)?源码如下
Option Explicit

'--------------------------------------------------------------------------
' 模 块: 取磁盘硬件信息处理类
' 版 本: 1.0
' 文件名: CDiskInfo.cls
' 作者: 林天炮
' 修改日期:2003-03-13

' 2003-04-02 艾会武 改动 aihuiwu@163.com
'
' 功能说明:获取硬盘序列号、型号、磁道扇区信息等
' 版权说明:此为共享代码,根据微软提供的例程改编,可以任意修改及使用,
' 作者对此模块运行所引起的错误不承担任何责任。
'
' 引用此模块时须保留作者署名,有意见或错误请发送至ltpao@sina.com
'
' 注意事项:支持Windows 95 OSR2, Windows 98, Windows NT, Windows 2000
' XP没有测试,估计没问题,在Win9X下必须保证存在SMARTVSD.vxd
'--------------------------------------------------------------------------

'/****************************************************************************
'* *
'* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY *
'* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE *
'* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR *
'* PURPOSE. *
'* *
'* Copyright 1993-98 Microsoft Corporation. All Rights Reserved. *
'* *
'****************************************************************************/

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
Private Const IDENTIFY_BUFFER_SIZE As Long = 512
Private Const READ_THRESHOLD_BUFFER_SIZE As Long = 512

'Private ndisk As String
'
' IOCTL commands
'
Private Const DFP_GET_VERSION As Long = &H74080
Private Const DFP_SEND_DRIVE_COMMAND As Long = &H7C084
Private Const DFP_RECEIVE_DRIVE_DATA As Long = &H7C088

'---------------------------------------------------------------------
' GETVERSIONOUTPARAMS contains the data returned from the
' Get Driver Version function.
'---------------------------------------------------------------------
Private Type GETVERSIONOUTPARAMS
bVersion As Byte ' Binary driver version.
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.
dwReserved(3) As Long ' For future use.
End Type

'
' Bits returned in the fCapabilities member of GETVERSIONOUTPARAMS
'
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
Private Const CAP_IDE_EXECUTE_SMART_FUNCTION As Long = 4 ' SMART commannds supported

'---------------------------------------------------------------------
' IDE registers
'---------------------------------------------------------------------
Private Type IDEREGS
bFeaturesReg As Byte ' Used for specifying SMART "commands".
bSectorCountReg As Byte ' IDE sector count register
bSectorNumberReg As Byte ' IDE sector number register
bCylLowReg As Byte ' IDE low order cylinder value
bCylHighReg As Byte ' IDE high order cylinder value
bDriveHeadReg As Byte ' IDE drive/head register
bCommandReg As Byte ' Actual IDE command.
bReserved As Byte ' reserved for future use. Must be zero.
End Type

'---------------------------------------------------------------------
' SENDCMDINPARAMS contains the input parameters for the
' Send Command to Drive function.
'---------------------------------------------------------------------
...全文
304 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwsh 2006-04-16
  • 打赏
  • 举报
回复
我找了个vb的exe,但是封装到dll里,asp里就得不到值了,不知道为什么?
wwsh 2006-04-16
  • 打赏
  • 举报
回复
那为什么dll里就得不到呢?
wanghui0380 2006-04-16
  • 打赏
  • 举报
回复
晕,vb嘛。这还用转载,是人都知道vb可以调用api,api可以得到硬盘号

to:BlueDestiny
你那个是卷标号,不是硬盘号
dh20156 2006-04-15
  • 打赏
  • 举报
回复
BlueDestiny,你这个只是获得了驱动器序列号而不是硬盘的序列号。
偶以前也遇到过这个问题,用VB写了一个DLL,在这个DLL里调用了一个VC的DLL,直接双击一个htm文件可以正常获得硬盘序列号,但是用http方式访问就不行,权限问题。
BlueDestiny 2006-04-15
  • 打赏
  • 举报
回复
Function ShowDriveInfo(drvpath)
Dim fso, d, s, t
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(drvpath)))
Select Case d.DriveType
Case 0: t = "未知"
Case 1: t = "可移动"
Case 2: t = "固定"
Case 3: t = "网络"
Case 4: t = "CD-ROM"
Case 5: t = "RAM 磁盘"
End Select
s = "驱动器 " & d.DriveLetter & ": - " & t
s = s & "<BR>" & "序列号:" & d.SerialNumber
ShowDriveInfo = s
End Function
ww_cain 2006-04-15
  • 打赏
  • 举报
回复
说说方法呀
擒兽 2006-04-14
  • 打赏
  • 举报
回复
代码真多,我只知道用FSO获取的话 IIS来宾帐号得拥有磁盘根目录的读取权限。
youzi520 2006-04-14
  • 打赏
  • 举报
回复

sungcong 2006-04-14
  • 打赏
  • 举报
回复
帮你顶下啦
ww_cain 2006-04-14
  • 打赏
  • 举报
回复
顶上去
ww_cain 2006-04-14
  • 打赏
  • 举报
回复
是呀,就是等你们回个话,我不能连续回帖呀?谢谢
Public Property Get pBytesPerTrack() As Long

pBytesPerTrack = VBIntegerToUShort(m_DiskInfo.wBytesPerTrack)

End Property

Public Property Get pBytesPerSector() As Long

pBytesPerSector = VBIntegerToUShort(m_DiskInfo.wBytesPerSector)

End Property

Public Property Get pSectorsPerTrack() As Long

pSectorsPerTrack = VBIntegerToUShort(m_DiskInfo.wSectorsPerTrack)

End Property

Public Property Get pSerialNumber() As String

pSerialNumber = StrConv(m_DiskInfo.sSerialNumber, vbUnicode)

End Property

Public Property Get pBufferType() As Long

pBufferType = VBIntegerToUShort(m_DiskInfo.wBufferType)

End Property

Public Property Get pBufferSize() As Long

pBufferSize = VBIntegerToUShort(m_DiskInfo.wBufferSize)

End Property

Public Property Get pECCSize() As Long

pECCSize = VBIntegerToUShort(m_DiskInfo.wECCSize)

End Property

Public Property Get pFirmwareRev() As String

pFirmwareRev = StrConv(m_DiskInfo.sFirmwareRev, vbUnicode)

End Property

Public Property Get pModelNumber() As String

pModelNumber = StrConv(m_DiskInfo.sModelNumber, vbUnicode)

End Property

Public Property Get pDoubleWordIO() As Long

pDoubleWordIO = VBIntegerToUShort(m_DiskInfo.wDoubleWordIO)

End Property

Public Property Get pCapabilities() As Long

pCapabilities = VBIntegerToUShort(m_DiskInfo.wCapabilities)

End Property

Public Property Get pPIOTiming() As Long

pPIOTiming = VBIntegerToUShort(m_DiskInfo.wPIOTiming)

End Property

Public Property Get pDMATiming() As Long

pDMATiming = VBIntegerToUShort(m_DiskInfo.wDMATiming)

End Property

Public Property Get pBS() As Long

pBS = VBIntegerToUShort(m_DiskInfo.wBS)

End Property

Public Property Get pNumCurrentCyls() As Long

pNumCurrentCyls = VBIntegerToUShort(m_DiskInfo.wNumCurrentCyls)

End Property

Public Property Get pNumCurrentHeads() As Long

pNumCurrentHeads = VBIntegerToUShort(m_DiskInfo.wNumCurrentHeads)

End Property

Public Property Get pNumCurrentSectorsPerTrack() As Long

pNumCurrentSectorsPerTrack = VBIntegerToUShort(m_DiskInfo.wNumCurrentSectorsPerTrack)

End Property

Public Property Get pCurrentSectorCapacity() As Long ' 2003-04-02 艾会武改
Dim s(4) As Byte
CopyMemory s(0), m_DiskInfo.ulCurrentSectorCapacity(0), 4
s(4) = 0
pCurrentSectorCapacity = ByteArrToLong(s)
End Property

Public Property Get pMultSectorStuff() As Long

pMultSectorStuff = VBIntegerToUShort(m_DiskInfo.wMultSectorStuff)

End Property

Public Property Get pTotalAddressableSectors() As Long '有效扇区数 ' 2003-04-02 艾会武改
Dim s(4) As Byte
CopyMemory s(0), m_DiskInfo.ulTotalAddressableSectors(0), 4
s(4) = 0
pTotalAddressableSectors = ByteArrToLong(s)
End Property

Public Property Get pSingleWordDMA() As Long

pSingleWordDMA = VBIntegerToUShort(m_DiskInfo.wSingleWordDMA)

End Property

Public Property Get pMultiWordDMA() As Long

pMultiWordDMA = VBIntegerToUShort(m_DiskInfo.wMultiWordDMA)

End Property

Private Function VBIntegerToUShort(ByVal i As Integer) As Long

Call CopyMemory(VBIntegerToUShort, i, 2)

End Function

':) Ulli's VB Code Formatter V2.10.8 (2003-03-14 18:04:52) 275 + 374 = 649 Lines


''------------2003-04-02 艾会武改
Private Function ByteArrToString(inByte() As Byte, ByVal strlen As Integer) As String
Dim i As Integer
For i = 0 To strlen
If inByte(i) = 0 Then
Exit For
End If
ByteArrToString = ByteArrToString & Chr(inByte(i))
Next i
End Function

Private Function ByteArrToLong(inByte() As Byte) As Long
Dim i As Integer
For i = 0 To 3
ByteArrToLong = ByteArrToLong + CDbl(inByte(i)) * (256 ^ i)
Next i

End Function
'-----------------------------------------
asp调用源码(dll已注册)
<%
Dim DataQuery,rs
Set DataQuery=Server.CreateObject("disk_info.CDiskInfo")
response.Write(DataQuery.pSerialNumber)
response.Write(DataQuery.pModelNumber)
%>
结束
wwsh 2006-04-14
  • 打赏
  • 举报
回复
好像代码没有完
ww_cain 2006-04-14
  • 打赏
  • 举报
回复

'/****************************************************************************
'*
'* DoEnableSMART
'*
'* FUNCTION: Send a SMART_ENABLE_SMART_OPERATIONS command to the drive
'* bDriveNum = 0-3
'*
'****************************************************************************/
Private Function DoEnableSMART(ByVal hSMARTIOCTL As Long, pSCIP As SENDCMDINPARAMS, pSCOP As SENDCMDOUTPARAMS, ByVal bDriveNum As Byte, lpcbBytesReturned As Long) As Boolean

'
' Set up data structures for Enable SMART Command.
'

pSCIP.cBufferSize = 0

pSCIP.irDriveRegs.bFeaturesReg = SMART_ENABLE_SMART_OPERATIONS
pSCIP.irDriveRegs.bSectorCountReg = 1
pSCIP.irDriveRegs.bSectorNumberReg = 1
pSCIP.irDriveRegs.bCylLowReg = SMART_CYL_LOW
pSCIP.irDriveRegs.bCylHighReg = SMART_CYL_HI

'
' Compute the drive number.
'
pSCIP.irDriveRegs.bDriveHeadReg = &HA0 Or ((bDriveNum And 1) * 2 ^ 4)
pSCIP.irDriveRegs.bCommandReg = IDE_EXECUTE_SMART_FUNCTION
pSCIP.bDriveNumber = bDriveNum

DoEnableSMART = CBool(DeviceIoControl(hSMARTIOCTL, DFP_SEND_DRIVE_COMMAND, _
pSCIP, LenB(pSCIP) - 1, _
pSCOP, LenB(pSCOP) - 1, _
lpcbBytesReturned, 0))

End Function

'---------------------------------------------------------------------
'---------------------------------------------------------------------
Private Sub ChangeByteOrder(szString() As Byte, ByVal uscStrSize As Integer)

Dim i As Integer
Dim bTemp As Byte

For i = 0 To uscStrSize - 1 Step 2
bTemp = szString(i)
szString(i) = szString(i + 1)
szString(i + 1) = bTemp
Next i

End Sub

'/****************************************************************************
'*
'* DisplayIdInfo
'*
'* Display the contents of the ID buffer
'*
'****************************************************************************/
Private Sub DisplayIdInfo(pids As IDSECTOR, pSCIP As SENDCMDINPARAMS, ByVal bIDCmd As Byte, ByVal bDfpDriveMap As Byte, ByVal bDriveNum As Byte)

ChangeByteOrder pids.sModelNumber, UBound(pids.sModelNumber) + 1

ChangeByteOrder pids.sFirmwareRev, UBound(pids.sFirmwareRev) + 1

ChangeByteOrder pids.sSerialNumber, UBound(pids.sSerialNumber) + 1

End Sub

'Public Function GetDiskInfo(ByVal nDrive As Byte) As Long
Public Function GetDiskInfo(ByVal nDrive As Byte) As Long

Dim hSMARTIOCTL As Long
Dim cbBytesReturned As Long
Dim VersionParams As GETVERSIONOUTPARAMS
Dim scip As SENDCMDINPARAMS
Dim scop() As Byte
Dim OutCmd As SENDCMDOUTPARAMS
Dim bDfpDriveMap As Byte
Dim bIDCmd As Byte ' IDE or ATAPI IDENTIFY cmd
Dim uDisk As IDSECTOR

' Clear buffer
m_DiskInfo = uDisk
'
' Try to get a handle to SMART IOCTL, report failure and exit if
' can't.
'
If nDrive = "" Then nDrive = 0
hSMARTIOCTL = OpenSMART(nDrive)
If hSMARTIOCTL <> INVALID_HANDLE_VALUE Then
'
' Get the version, etc of SMART IOCTL
'

Call DeviceIoControl(hSMARTIOCTL, DFP_GET_VERSION, ByVal 0, 0, VersionParams, Len(VersionParams), cbBytesReturned, 0)

'
' If there is a IDE device at number "nDrive" issue commands
' to the device.
'
'if (VersionParams.bIDEDeviceMap >> nDrive & 1)
'{

'
' Try to enable SMART so we can tell if a drive supports it.
' Ignore ATAPI devices.
'

If Not (VersionParams.bIDEDeviceMap \ 2 ^ nDrive And &H10) Then
If DoEnableSMART(hSMARTIOCTL, scip, OutCmd, nDrive, cbBytesReturned) Then
'
' Mark the drive as SMART enabled
'
bDfpDriveMap = bDfpDriveMap Or 2 ^ nDrive
End If
End If

'
' Now, get the ID sector for all IDE devices in the system.
' If the device is ATAPI use the IDE_ATAPI_ID command,
' otherwise use the IDE_ID_FUNCTION command.
'
bIDCmd = IIf((VersionParams.bIDEDeviceMap \ 2 ^ nDrive And &H10), IDE_ATAPI_ID, IDE_ID_FUNCTION)

ReDim scop(LenB(OutCmd) + IDENTIFY_BUFFER_SIZE - 1) As Byte
If DoIDENTIFY(hSMARTIOCTL, scip, scop, bIDCmd, nDrive, cbBytesReturned) Then
CopyMemory m_DiskInfo, scop(LenB(OutCmd) - 4), LenB(m_DiskInfo)
Call DisplayIdInfo(m_DiskInfo, scip, bIDCmd, bDfpDriveMap, nDrive)
'
' Close SMART.
'
CloseHandle hSMARTIOCTL
GetDiskInfo = 1
Exit Function '>---> Bottom
End If
'}
'
' Close SMART.
'
CloseHandle hSMARTIOCTL
GetDiskInfo = 0
Else 'NOT HSMARTIOCTL...
GetDiskInfo = -1
End If

End Function

Public Property Get pGenConfig() As Long

pGenConfig = VBIntegerToUShort(m_DiskInfo.wGenConfig)

End Property

Public Property Get pNumCyls() As Long

pNumCyls = VBIntegerToUShort(m_DiskInfo.wNumCyls)

End Property

Public Property Get pNumHeads() As Long

pNumHeads = VBIntegerToUShort(m_DiskInfo.wNumHeads)

End Property
ww_cain 2006-04-14
  • 打赏
  • 举报
回复
Private Declare Function GetVersionEx Lib "KERNEL32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Private Const CREATE_NEW As Long = 1
Private Const GENERIC_READ As Long = &H80000000
Private Const GENERIC_WRITE As Long = &H40000000
Private Const FILE_SHARE_READ As Long = &H1
Private Const FILE_SHARE_WRITE As Long = &H2
Private Const OPEN_EXISTING As Long = 3
Private Declare Function CreateFile Lib "KERNEL32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function DeviceIoControl Lib "KERNEL32" (ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, ByVal lpOverlapped As Long) As Long
Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function CloseHandle Lib "KERNEL32" (ByVal hObject As Long) As Long

'
' Define global buffers.
'
Private m_DiskInfo As IDSECTOR

'---------------------------------------------------------------------
' Open SMART to allow DeviceIoControl communications.
'---------------------------------------------------------------------
Private Function OpenSMART(ByVal nDrive As Byte) As Long

Dim hSMARTIOCTL As Long
Dim hd As String
Dim VersionInfo As OSVERSIONINFO

hSMARTIOCTL = INVALID_HANDLE_VALUE
VersionInfo.dwOSVersionInfoSize = Len(VersionInfo)
GetVersionEx VersionInfo
Select Case VersionInfo.dwPlatformId
Case VER_PLATFORM_WIN32s
OpenSMART = hSMARTIOCTL
Case VER_PLATFORM_WIN32_WINDOWS
' Version Windows 95 OSR2, Windows 98
hSMARTIOCTL = CreateFile("\\.\SMARTVSD", 0, 0, 0, CREATE_NEW, 0, 0)
Case VER_PLATFORM_WIN32_NT
' Windows NT, Windows 2000
If nDrive < MAX_IDE_DRIVES Then
hd = "\\.\PhysicalDrive" & nDrive
hSMARTIOCTL = CreateFile(hd, GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0)
End If
End Select
OpenSMART = hSMARTIOCTL

End Function

'/****************************************************************************
'*
'* DoIDENTIFY
'*
'* FUNCTION: Send an IDENTIFY command to the drive
'* bDriveNum = 0-3
'* bIDCmd = IDE_ID_FUNCTION or IDE_ATAPI_ID
'*
'****************************************************************************/
Private Function DoIDENTIFY(ByVal hSMARTIOCTL As Long, pSCIP As SENDCMDINPARAMS, pSCOP() As Byte, ByVal bIDCmd As Byte, ByVal bDriveNum As Byte, lpcbBytesReturned As Long) As Boolean

'
' Set up data structures for IDENTIFY command.
'

pSCIP.cBufferSize = IDENTIFY_BUFFER_SIZE

pSCIP.irDriveRegs.bFeaturesReg = 0
pSCIP.irDriveRegs.bSectorCountReg = 1
pSCIP.irDriveRegs.bSectorNumberReg = 1
pSCIP.irDriveRegs.bCylLowReg = 0
pSCIP.irDriveRegs.bCylHighReg = 0

'
' Compute the drive number.
'
pSCIP.irDriveRegs.bDriveHeadReg = &HA0 Or ((bDriveNum And 1) * 2 ^ 4)

'
' The command can either be IDE identify or ATAPI identify.
'
pSCIP.irDriveRegs.bCommandReg = bIDCmd
pSCIP.bDriveNumber = bDriveNum
pSCIP.cBufferSize = IDENTIFY_BUFFER_SIZE


'原 DoIDENTIFY = CBool(DeviceIoControl(hSMARTIOCTL, DFP_RECEIVE_DRIVE_DATA, _
pSCIP, LenB(pSCIP) - 1, _
pSCOP(0), UBound(pSCOP), _
lpcbBytesReturned, 0))
'2003-04-02 艾会武改
DoIDENTIFY = CBool(DeviceIoControl(hSMARTIOCTL, DFP_RECEIVE_DRIVE_DATA, _
pSCIP, 32, _
pSCOP(0), 528, _
lpcbBytesReturned, 0))

End Function
ww_cain 2006-04-14
  • 打赏
  • 举报
回复
Private Type SENDCMDINPARAMS
cBufferSize As Long ' Buffer size in bytes
irDriveRegs As IDEREGS ' Structure with drive register values.
bDriveNumber As Byte ' Physical drive number to send
' command to (0,1,2,3).
bReserved(2) As Byte ' Reserved for future expansion.
dwReserved(3) As Long ' For future use.
bBuffer(0) As Byte ' Input buffer.
End Type

'
' Valid values for the bCommandReg member of IDEREGS.
'
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.
Private Const IDE_EXECUTE_SMART_FUNCTION As Long = &HB0 ' Performs SMART cmd.
' Requires valid bFeaturesReg,
' bCylLowReg, and bCylHighReg
'
' Cylinder register values required when issuing SMART command
'
Private Const SMART_CYL_LOW As Long = &H4F
Private Const SMART_CYL_HI As Long = &HC2

'---------------------------------------------------------------------
' Status returned from driver
'---------------------------------------------------------------------
Private Type DRIVERSTATUS
bDriverError As Byte ' Error code from driver,
' or 0 if no error.
bIDEStatus As Byte ' Contents of IDE Error register.
' Only valid when bDriverError
' is SMART_IDE_ERROR.
bReserved(1) As Byte ' Reserved for future expansion.
dwReserved(1) As Long ' Reserved for future expansion.
End Type

'
' bDriverError values
'
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 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 SMART_INVALID_REGISTER As Long = 8 ' Some IDE Register not valid
Private Const SMART_NOT_SUPPORTED As Long = 9 ' Invalid cmd flag set
Private Const SMART_NO_IDE_DEVICE As Long = 10 ' Cmd issued to device not present
' although drive number is valid
' 11-255 reserved

'---------------------------------------------------------------------
' Structure returned by SMART IOCTL for several commands
'---------------------------------------------------------------------
Private Type SENDCMDOUTPARAMS
cBufferSize As Long ' Size of bBuffer in bytes
drvStatus As DRIVERSTATUS ' Driver status structure.
bBuffer(0) As Byte ' Buffer of arbitrary length in which to store the data read from the ' drive.
End Type

'---------------------------------------------------------------------
' Feature register defines for SMART "sub commands"
'---------------------------------------------------------------------
Private Const SMART_READ_ATTRIBUTE_VALUES As Long = &HD0 ' ATA4: Renamed
' SMART READ DATA
Private Const SMART_READ_ATTRIBUTE_THRESHOLDS As Long = &HD1 ' Obsoleted in ATA4!
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
' Vendor specific commands:
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

'---------------------------------------------------------------------
' The following structure defines the structure of a Drive Attribute
'---------------------------------------------------------------------
Private Type DRIVEATTRIBUTE
bAttrID As Byte ' Identifies which attribute
wStatusFlags As Integer ' see bit definitions below
bAttrValue As Byte ' Current normalized value
bWorstValue As Byte ' How bad has it ever been?
bRawValue(5) As Byte ' Un-normalized value
bReserved As Byte ' ...
End Type

'---------------------------------------------------------------------
' The following structure defines the structure of a Warranty Threshold
' Obsoleted in ATA4!
'---------------------------------------------------------------------
Private Type ATTRTHRESHOLD
bAttrID As Byte ' Identifies which attribute
bWarrantyThreshold As Byte ' Triggering value
bReserved(9) As Byte ' ...
End Type

'---------------------------------------------------------------------
' The following struct defines the interesting part of the IDENTIFY
' buffer:
'---------------------------------------------------------------------
Private Type IDSECTOR
wGenConfig As Integer
wNumCyls As Integer
wReserved As Integer
wNumHeads As Integer
wBytesPerTrack As Integer
wBytesPerSector As Integer
wSectorsPerTrack As Integer
wVendorUnique(2) As Integer
sSerialNumber(19) As Byte
wBufferType As Integer
wBufferSize As Integer
wECCSize As Integer
sFirmwareRev(7) As Byte
sModelNumber(39) As Byte
wMoreVendorUnique As Integer
wDoubleWordIO As Integer
wCapabilities As Integer
wReserved1 As Integer
wPIOTiming As Integer
wDMATiming As Integer
wBS As Integer
wNumCurrentCyls As Integer
wNumCurrentHeads As Integer
wNumCurrentSectorsPerTrack As Integer
ulCurrentSectorCapacity(3) As Byte '这里只能用byte,因为VB没有无符号的LONG型变量
wMultSectorStuff As Integer
ulTotalAddressableSectors(3) As Byte '这里只能用byte,因为VB没有无符号的LONG型变量
wSingleWordDMA As Integer
wMultiWordDMA As Integer
bReserved(127) As Byte
End Type

'---------------------------------------------------------------------
' Valid Attribute IDs
'---------------------------------------------------------------------
Private Const ATTR_INVALID As Long = 0
Private Const ATTR_READ_ERROR_RATE As Long = 1
Private Const ATTR_THROUGHPUT_PERF As Long = 2
Private Const ATTR_SPIN_UP_TIME As Long = 3
Private Const ATTR_START_STOP_COUNT As Long = 4
Private Const ATTR_REALLOC_SECTOR_COUNT As Long = 5
Private Const ATTR_READ_CHANNEL_MARGIN As Long = 6
Private Const ATTR_SEEK_ERROR_RATE As Long = 7
Private Const ATTR_SEEK_TIME_PERF As Long = 8
Private Const ATTR_POWER_ON_HRS_COUNT As Long = 9
Private Const ATTR_SPIN_RETRY_COUNT As Long = 10
Private Const ATTR_CALIBRATION_RETRY_COUNT As Long = 11
Private Const ATTR_POWER_CYCLE_COUNT As Long = 12

'---------------------------------------------------------------------
' Status Flags Values
'---------------------------------------------------------------------
Private Const PRE_FAILURE_WARRANTY As Long = &H1
Private Const ON_LINE_COLLECTION As Long = &H2
Private Const PERFORMANCE_ATTRIBUTE As Long = &H4
Private Const ERROR_RATE_ATTRIBUTE As Long = &H8
Private Const EVENT_COUNT_ATTRIBUTE As Long = &H10
Private Const SELF_PRESERVING_ATTRIBUTE As Long = &H20

Private Const NUM_ATTRIBUTE_STRUCTS As Long = 30

Private Const INVALID_HANDLE_VALUE As Long = -1

Private Const VER_PLATFORM_WIN32s As Long = 0
Private Const VER_PLATFORM_WIN32_WINDOWS As Long = 1
Private Const VER_PLATFORM_WIN32_NT As Long = 2
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type
ww_cain 2006-04-14
  • 打赏
  • 举报
回复
来人呀!!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧