'[FONT=Arial][SIZE=1]********************START OF BAS MODULE********************
Option Explicit
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (LpVersionInformation As OSVERSIONINFO) As Long
Private Type ATTR_DATA
AttrID As Byte
AttrName As String
AttrValue As Byte
ThresholdValue As Byte
WorstValue As Byte
StatusFlags As STATUS_FLAGS
End Type
Public Type DRIVE_INFO
bDriveType As Byte
SerialNumber As String
Model As String
FirmWare As String
Cilinders As Long
Heads As Long
SecPerTrack As Long
BytesPerSector As Long
BytesperTrack As Long
NumAttributes As Byte
Attributes() As ATTR_DATA
End Type
Public Enum IDE_DRIVE_NUMBER
PRIMARY_MASTER
PRIMARY_SLAVE
SECONDARY_MASTER
SECONDARY_SLAVE
End Enum
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 CloseHandle _
Lib "kernel32" (ByVal hObject 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
Public Declare Sub CopyMemory _
Lib "kernel32" _
Alias "RtlMoveMemory" (Destination As Any, _
Source As Any, ByVal Length As Long)
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Const OPEN_EXISTING = 3
Private Const FILE_ATTRIBUTE_SYSTEM = &H4
Private Const CREATE_NEW = 1
Private Const INVALID_HANDLE_VALUE = -1
Dim di As DRIVE_INFO
Public Const MAX_IDE_DRIVES = 4
' // Max number of drives assuming primary/secondary, master/slavetopology
Public Const READ_ATTRIBUTE_BUFFER_SIZE = 512
Public Const IDENTIFY_BUFFER_SIZE = 512
Public Const READ_THRESHOLD_BUFFER_SIZE = 512
Public Const OUTPUT_DATA_SIZE = IDENTIFY_BUFFER_SIZE + 16
'IOCTL commands
Public Const DFP_GET_VERSION = &H74080
Public Const DFP_SEND_DRIVE_COMMAND = &H7C084
Public Const DFP_RECEIVE_DRIVE_DATA = &H7C088
'---------------------------------------------------------------------
' GETVERSIONOUTPARAMS contains the data returned from the
' Get Driver Version function.
'---------------------------------------------------------------------
Public 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
Public Const CAP_IDE_ID_FUNCTION = 1 ' ATA ID commandsupported
Public Const CAP_IDE_ATAPI_ID = 2 ' ATAPI ID commandsupported
Public Const CAP_IDE_EXECUTE_SMART_FUNCTION = 4 ' SMART commanndssupported
'---------------------------------------------------------------------
' IDE registers
'---------------------------------------------------------------------
Public 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 bezero.
End Type
'---------------------------------------------------------------------
' SENDCMDINPARAMS contains the input parameters for the
' Send Command to Drive function.
'---------------------------------------------------------------------
Public 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 commandto(0,1,2,3).
bReserved(2) As Byte ' Bytes reserved
dwReserved(3) As Long ' DWORDS reserved
bBuffer() As Byte ' Input buffer.
End Type
' Valid values for the bCommandReg member of IDEREGS.
Public Const IDE_ATAPI_ID = &HA1 ' Returns ID sector for
'ATAPI.
Public Const IDE_ID_FUNCTION = &HEC ' Returns ID sector for
'ATA.
Public Const IDE_EXECUTE_SMART_FUNCTION = &HB0 ' Performs SMART cmd.
' Requires valid
'bFeaturesReg,
' bCylLowReg, andbCylHighRe
' Cylinder register values required when issuing SMART command
Public Const SMART_CYL_LOW = &H4F
Public Const SMART_CYL_HI = &HC2
'---------------------------------------------------------------------
' Status returned from driver
'---------------------------------------------------------------------
Public 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
dwReserved(1) As Long
End Type
' bDriverError values
Public Enum DRIVER_ERRORS
SMART_NO_ERROR = 0 ' No error
SMART_IDE_ERROR = 1 ' Error from IDE controller
SMART_INVALID_FLAG = 2 ' Invalid command flag
SMART_INVALID_COMMAND = 3 ' Invalid command byte
SMART_INVALID_BUFFER = 4 ' Bad buffer (null, invalid addr..)
SMART_INVALID_DRIVE = 5 ' Drive number not valid
SMART_INVALID_IOCTL = 6 ' Invalid IOCTL
SMART_ERROR_NO_MEM = 7 ' Could not lock user's buffer
SMART_INVALID_REGISTER = 8 ' Some IDE Register not valid
SMART_NOT_SUPPORTED = 9 ' Invalid cmd flag set
SMART_NO_IDE_DEVICE = 10 ' Cmd issued to device not present
' although drive number is valid
' 11-255 reserved
End Enum
'---------------------------------------------------------------------
' The following struct defines the interesting part of the IDENTIFY
' buffer:
'---------------------------------------------------------------------
Public 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 As Long
wMultSectorStuff As Integer
ulTotalAddressableSectors As Long
wSingleWordDMA As Integer
wMultiWordDMA As Integer
bReserved(127) As Byte
End Type
....
[/FONT][/SIZE]
(i had to cut it down because of the maxlen of this post*grr*)
i only found this bas module in this forum.
ok it works but how do i get out the live temperature ?
thanks :)
lglmi