Attribute VB_Name = "modIDE"
Option Explicit
' Create user-defined type
Public Type TypeHddInfo
DoubleTransfer As Long
ControllerType As Long
BufferSize As Long
ECCMode As Long
SectorsPerInterrupt As Long
Cylinders As Long
Heads As Long
SectorsPerTrack As Long
Model As String * 41
SerialNumber As String * 21
Revision As String * 9
End Type
Public Declare Function OpenTVicHW32 Lib "TVicHW32.DLL" (ByVal HW32 As Long, ByVal ServiceName As String, ByVal EntryPoint As String) As Long
Public Declare Function CloseTVicHW32 Lib "TVicHW32.DLL" (ByVal HW32 As Long) As Long
Public Declare Function GetActiveHW Lib "TVicHW32.DLL" (ByVal HW32 As Long) As Long
Public Declare Sub GetHDDInfo Lib "TVicHW32.DLL" (ByVal HW32 As Long, ByVal IdeNumber As Integer, ByVal Master As Integer, ByRef Info As TypeHddInfo)
Public HddInfo As TypeHddInfo
Public IDEMNo As String
Public IDESNo As String
Public Sub GetIDEInfo()
Dim HW32 As Long
Dim TVicDevice0 As String
On Error GoTo ErrorTrap
HW32 = 0
HW32 = OpenTVicHW32(HW32, "TVICHW32", "TVicDevice0")
If GetActiveHW(HW32) = 0 Then GoTo ErrorTrap
Call GetHDDInfo(HW32, 1, 1, HddInfo)
Call FilterInfo
HW32 = CloseTVicHW32(HW32)
Exit Sub
ErrorTrap:
MsgBox ("存取IDE資料錯誤"), 48
End Sub
Public Sub FilterInfo()
Dim k As Long
Dim OldString As String, NewString As String, TempChr As String
OldString = Trim(HddInfo.Model)
NewString = ""
For k = 1 To Len(OldString)
TempChr = Mid(OldString, k, 1)
If Asc(TempChr) > 32 And Asc(TempChr) < 127 Then
NewString = NewString & TempChr
End If
Next k
IDEMNo = NewString
OldString = Trim(HddInfo.SerialNumber)
NewString = ""
For k = 1 To Len(OldString)
TempChr = Mid(OldString, k, 1)
If Asc(TempChr) > 32 And Asc(TempChr) < 127 Then
NewString = NewString & TempChr
End If
Next k
IDESNo = NewString
End Sub