home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Data_CD_Wr2028081112006.psc / Burn / clsASPI.cls next >
Text File  |  2006-10-26  |  18KB  |  642 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "clsASPI"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15.  
  16. Private Declare Function DeviceIoControl Lib "kernel32" ( _
  17.     ByVal hDevice As Long, _
  18.     ByVal dwIoControlCode As Long, _
  19.     ByRef lpInBuffer As Any, _
  20.     ByVal nInBufferSize As Long, _
  21.     ByRef lpOutBuffer As Any, _
  22.     ByVal nOutBufferSize As Long, _
  23.     ByRef lpBytesReturned As Long, _
  24.     lpOverlapped As Any _
  25. ) As Long
  26.  
  27. Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" ( _
  28.     ByVal lpFileName As String, _
  29.     ByVal dwDesiredAccess As Long, _
  30.     ByVal dwShareMode As Long, _
  31.     ByVal lpSecurityAttributes As Long, _
  32.     ByVal dwCreationDisposition As Long, _
  33.     ByVal dwFlagsAndAttributes As Long, _
  34.     ByVal hTemplateFile As Long _
  35. ) As Long
  36.  
  37. Private Declare Sub ZeroMemory Lib "kernel32.dll" _
  38. Alias "RtlZeroMemory" ( _
  39.     Destination As Any, _
  40.     ByVal Length As Long _
  41. )
  42.  
  43. Private Declare Sub CopyMemory Lib "kernel32" _
  44. Alias "RtlMoveMemory" ( _
  45.     pDst As Any, _
  46.     pSrc As Any, _
  47.     ByVal ByteLen As Long _
  48. )
  49.  
  50. Private Declare Function WaitForSingleObject Lib "kernel32" ( _
  51.     ByVal hHandle As Long, _
  52.     ByVal dwMS As Long _
  53. ) As Long
  54.  
  55. Private Declare Function CreateEvent Lib "kernel32" _
  56. Alias "CreateEventA" ( _
  57.     ByVal lpEventAttributes As Long, _
  58.     ByVal bManualReset As Long, _
  59.     ByVal bInitialState As Long, _
  60.     ByVal lpname As String _
  61. ) As Long
  62.  
  63. Private Declare Function ResetEvent Lib "kernel32" ( _
  64.     ByVal hEvent As Long _
  65. ) As Long
  66.  
  67. Private Declare Function CloseHandle Lib "kernel32" ( _
  68.     ByVal hObject As Long _
  69. ) As Long
  70.  
  71. Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" ( _
  72.     ByVal nDrive As String _
  73. ) As Long
  74.  
  75. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" ( _
  76.     lpVersionInformation As OSVERSIONINFOEX _
  77. ) As Long
  78.  
  79. Private Declare Sub Sleep Lib "kernel32" (ByVal ms As Long)
  80.  
  81. Private Const WAIT_FAILED            As Long = &HFFFFFFFF
  82. Private Const WAIT_OBJECT_0          As Long = &H0&
  83. Private Const WAIT_ABANDONED         As Long = &H80&
  84. Private Const WAIT_TIMEOUT           As Long = &H102&
  85.  
  86. Private Const INVALID_HANDLE_VALUE   As Long = -1
  87. Private Const OPEN_EXISTING          As Long = &H3
  88. Private Const GENERIC_READ           As Long = &H80000000
  89. Private Const GENERIC_WRITE          As Long = &H40000000
  90. Private Const FILE_SHARE_READ        As Long = &H1
  91. Private Const FILE_SHARE_WRITE       As Long = &H2
  92. Private Const FILE_ATTRIBUTE_NORMAL  As Long = &H80
  93.  
  94. Private Const VER_PLATFORM_WIN32_NT  As Long = &H2
  95. Private Const IOCTL_SCSI_GET_ADDRESS As Long = &H41018
  96.  
  97. Private Type OSVERSIONINFOEX
  98.     dwOSVersionInfoSize As Long
  99.     dwMajorVersion      As Long
  100.     dwMinorVersion      As Long
  101.     dwBuildNumber       As Long
  102.     dwPlatformId        As Long
  103.     szCSDVersion        As String * 128
  104. End Type
  105.  
  106. Private Type t_SCSI_ADDRESS
  107.     Length              As Long
  108.     PortNumber          As Byte
  109.     PathId              As Byte
  110.     TargetID            As Byte
  111.     LUN                 As Byte
  112. End Type
  113.  
  114. Private Type t_HAID
  115.     HA                  As Byte
  116.     ID                  As Byte
  117.     LUN                 As Byte
  118. End Type
  119.  
  120. Private Type SRB
  121.     SRB_Cmd             As Byte
  122.     SRB_Status          As Byte
  123.     SRB_HAID            As Byte
  124.     SRB_Flags           As Byte
  125.     SRB_Hdr_Rsvd        As Long
  126. End Type
  127.  
  128. Private Type SRB_HAInquiry
  129.     HA_Hdr              As SRB
  130.     HA_Count            As Byte
  131.     HA_Id               As Byte
  132.     HA_MgrId            As String * 16
  133.     HA_Ident            As String * 16
  134.     HA_Unique(15)       As Byte
  135.     HA_Rsvd             As Integer
  136.     HA_Pad(19)          As Byte
  137. End Type
  138.  
  139. Private Type SRB_GetDevType
  140.     SRB_Hdr             As SRB
  141.     SRB_Target          As Byte
  142.     SRB_LUN             As Byte
  143.     DEV_DeviceType      As Byte
  144.     DEV_Rsvd1           As Byte
  145.     DEV_Pad(67)         As Byte
  146. End Type
  147.  
  148. Private Type SRB_GetDiskInfo
  149.     SRB_Hdr             As SRB
  150.     SRB_Target          As Byte
  151.     SRB_LUN             As Byte
  152.     SRB_DriveFlags      As Byte
  153.     SRB_Int13DrvInfo    As Byte
  154.     SRB_Heads           As Byte
  155.     SRB_Sectors         As Byte
  156.     SRB_Rsvd1(9)        As Byte
  157. End Type
  158.  
  159. Private Type SRB_ExecuteIO
  160.     SRB_Hdr             As SRB
  161.     SRB_Target          As Byte
  162.     SRB_LUN             As Byte
  163.     SRB_Rsvd1           As Integer
  164.     SRB_BufLen          As Long
  165.     SRB_BufPointer      As Long
  166.     SRB_SenseLen        As Byte
  167.     SRB_CDBLen          As Byte
  168.     SRB_HaStat          As Byte
  169.     SRB_TargStat        As Byte
  170.     SRB_PostProc        As Long
  171.     SRB_Rsvd2(19)       As Byte
  172.     SRB_CDBByte(15)     As Byte
  173.     SRB_SenseData(15)   As Byte
  174. End Type
  175.  
  176. Private Type SRB_Abort
  177.     SRB_Hdr             As SRB
  178.     SRB_SRBAbort        As Long
  179. End Type
  180.  
  181. Private Type SRB_BusDecviceReset
  182.     SRB_Hdr             As SRB
  183.     SRB_Target          As Byte
  184.     SRB_LUN             As Byte
  185.     SRB_Rsvd1(11)       As Byte
  186.     SRB_HaStat          As Byte
  187.     SRB_TargStat        As Byte
  188.     SRB_PostProc        As Long
  189.     SRB_Rsvd2(35)       As Byte
  190. End Type
  191.  
  192. Private Type SRB_GetSetTimeouts
  193.     SRB_Hdr             As SRB
  194.     SRB_Target          As Byte
  195.     SRB_LUN             As Byte
  196.     SRB_Timeout         As Long
  197. End Type
  198.  
  199. Private Enum SRB_Command
  200.     SC_HA_INQUIRY = &H0
  201.     SC_GET_DEV_TYPE = &H1
  202.     SC_EXEC_SCSI_CMD = &H2
  203.     SC_ABORT_SRB = &H3
  204.     SC_RESET_DEV = &H4
  205.     SC_SET_HA_PARMS = &H5
  206.     SC_GET_DISK_INFO = &H6
  207.     SC_RESCAN_SCSI_BUS = &H7
  208.     SC_GETSET_TIMEOUTS = &H8
  209. End Enum
  210.  
  211. Private Enum HA_Status
  212.     HASTAT_OK = &H0
  213.     HASTAT_SEL_TO = &H11
  214.     HASTAT_DO_DU = &H12
  215.     HASTAT_BUS_FREE = &H13
  216.     HASTAT_PHASE_ERR = &H14
  217.     HASTAT_TIMEOUT = &H9
  218.     HASTAT_COMMAND_TIMEOUT = &HB
  219.     HASTAT_MESSAGE_REJECT = &HD
  220.     HASTAT_BUS_RESET = &HE
  221.     HASTAT_PARITY_ERROR = &HF
  222.     HASTAT_REQUEST_SENSE_FAILED = &H10
  223. End Enum
  224.  
  225. Private Enum SRB_Status
  226.     SS_PENDING = &H0
  227.     SS_COMP = &H1
  228.     SS_ABORTED = &H2
  229.     SS_ABORT_FAIL = &H3
  230.     SS_ERR = &H4
  231.     SS_INVALID_CMD = &H80
  232.     SS_INVALID_HA = &H81
  233.     SS_NO_DEVICE = &H82
  234.     SS_INVALID_SRB = &HE0
  235.     SS_BUFFER_ALIGN = &HE1
  236.     SS_ILLEGAL_MODE = &HE2
  237.     SS_NO_ASPI = &HE3
  238.     SS_FAILED_INIT = &HE4
  239.     SS_ASPI_IS_BUSY = &HE5
  240.     SS_BUFFER_TO_BIG = &HE6
  241.     SS_MISMATCHED_COMPONENTS = &HE7
  242.     SS_NO_ADAPTERS = &HE8
  243.     SS_INSUFFICIENT_RESOURCES = &HE9
  244.     SS_ASPI_IS_SHUTDOWN = &HEA
  245.     SS_BAD_INSTALL = &HBE
  246. End Enum
  247.  
  248. Private Enum SRB_Flags
  249.     SRB_POSTING = &H1
  250.     SRB_ENABLE_RESIDUAL_COUNT = &H4
  251.     SRB_DIR_IN = &H8
  252.     SRB_DIR_OUT = &H10
  253.     SRB_DIR_NOTIFY = &H40
  254. End Enum
  255.  
  256. Private Enum DevTypes
  257.     DTYPE_DASD = 0              ' direct access device
  258.     DTYPE_SEQD = 1              ' sequential-access device
  259.     DTYPE_PRNT = 2              ' Printer
  260.     DTYPE_PROC = 3              ' Processor
  261.     DTYPE_WORM = 4              ' Write-once device
  262.     DTYPE_CDROM = 5             ' CD/DVD-ROM
  263.     DTYPE_SCAN = 6              ' Scanner
  264.     DTYPE_OPTI = 7              ' Optical Memory Device
  265.     DTYPE_JUKE = 8              ' Changer
  266.     DTYPE_COMM = 9              ' Communication device
  267.     DTYPE_UNKNOWN = &H1F        ' unknown device
  268. End Enum
  269.  
  270. Private Const SENSE_LEN As Long = 14&
  271. Private Const MAX_SRB_TIMEOUT As Long = 108000
  272. Private Const DEFAULT_SRB_TIMEOUT As Long = 108000
  273.  
  274. Private ASPILib         As clsCDECL
  275. Private blnASPIInst     As Boolean
  276.  
  277. Private Const FNC_INFO  As String = "GetASPI32SupportInfo"
  278. Private Const FNC_CMD   As String = "SendASPI32Command"
  279.  
  280.  
  281. Private colDrives       As Collection
  282.  
  283. Private btLastSK        As Byte
  284. Private btLastASC       As Byte
  285. Private btLastASCQ      As Byte
  286.  
  287. Implements ISCSI
  288.  
  289. Private Function GetDriveHandle(ByVal drv As String, ByRef fh As Long) As Boolean
  290.     Dim flags   As Long
  291.  
  292.     ' starting from win 2k you also need GENERIC_WRITE
  293.     flags = GENERIC_READ
  294.     If IsW2K Then flags = flags Or GENERIC_WRITE
  295.  
  296.     ' get the handle with CreateFile().
  297.     ' you can access drives with "\\.\X:", where X is the drive's char.
  298.     fh = CreateFile("\\.\" & Left$(drv, 1) & ":", flags, _
  299.                     FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0, _
  300.                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, ByVal 0)
  301.  
  302.     GetDriveHandle = fh <> -1
  303.  
  304. End Function
  305.  
  306. Private Function DriveCharWin9x(ByVal HA As Byte, ByVal ID As Byte, ByVal LUN As Byte) As String
  307.     Dim diskinfo As SRB_GetDiskInfo
  308.  
  309.     diskinfo.SRB_Hdr.SRB_Cmd = SC_GET_DISK_INFO
  310.     diskinfo.SRB_Hdr.SRB_Flags = SRB_DIR_IN
  311.     diskinfo.SRB_Hdr.SRB_HAID = HA
  312.     diskinfo.SRB_Target = ID
  313.     diskinfo.SRB_LUN = LUN
  314.  
  315.     SRBDiskInfo diskinfo
  316.  
  317.     DriveCharWin9x = Chr$(diskinfo.SRB_Int13DrvInfo + 65)
  318.  
  319. End Function
  320.  
  321. Private Function DriveCharWinNT(ByVal HA As Byte, ByVal ID As Byte, ByVal LUN As Byte) As String
  322.  
  323.     Dim haid    As t_HAID
  324.     Dim i       As Long
  325.  
  326.     'go through all 26 possible drives
  327.     For i = 1 To 26
  328.  
  329.         'CD-ROM?
  330.         If GetDriveType(Chr(i + 64) & ":") = 5 Then
  331.  
  332.             'compare to the parameters
  333.             If NTGetHAID(Chr$(i + 64), haid) Then
  334.                 If haid.HA = HA And _
  335.                    haid.ID = ID And _
  336.                    haid.LUN = LUN Then
  337.                     'found it!
  338.                     DriveCharWinNT = Chr$(i + 64)
  339.                 End If
  340.             End If
  341.  
  342.         End If
  343.  
  344.     Next
  345.  
  346. End Function
  347.  
  348. Private Function NTGetHAID(ByVal strDrv As String, ByRef haid As t_HAID) As Boolean
  349.  
  350.     Dim returned    As Long, Status As Long
  351.     Dim fh          As Long, i      As Long
  352.  
  353.     Dim pscsiAddr   As t_SCSI_ADDRESS
  354.  
  355.     'get drive handle
  356.     If GetDriveHandle(Left$(strDrv, 1), fh) Then
  357.  
  358.         'get SCSI address
  359.         pscsiAddr.Length = Len(pscsiAddr)
  360.         Status = DeviceIoControl(fh, IOCTL_SCSI_GET_ADDRESS, _
  361.                                  pscsiAddr, Len(pscsiAddr), _
  362.                                  pscsiAddr, Len(pscsiAddr), _
  363.                                  returned, ByVal 0&)
  364.  
  365.         CloseHandle fh
  366.  
  367.         'success?
  368.         If Status = 1 Then
  369.             With pscsiAddr
  370.                 haid.HA = .PortNumber
  371.                 haid.ID = .TargetID
  372.                 haid.LUN = .LUN
  373.                 NTGetHAID = True
  374.                 Exit Function
  375.             End With
  376.         End If
  377.  
  378.     End If
  379.  
  380. End Function
  381.  
  382. Private Sub FindDrives()
  383.     Dim HACnt   As Integer
  384.     Dim IDCnt   As Integer
  385.     Dim LUNCnt  As Integer
  386.     Dim HAInq   As SRB_HAInquiry
  387.     Dim DevTyp  As SRB_GetDevType
  388.  
  389.     ' Host Adapters
  390.     HACnt = LoByte(LoWord(ASPILib.CallFunc(FNC_INFO)))
  391.  
  392.     For HACnt = 0 To HACnt
  393.  
  394.         For IDCnt = 0 To 7
  395.  
  396.             For LUNCnt = 0 To 7
  397.  
  398.                 ZeroMemory DevTyp, LenB(DevTyp)
  399.                 DevTyp.SRB_Hdr.SRB_Cmd = SC_GET_DEV_TYPE
  400.                 DevTyp.SRB_Hdr.SRB_HAID = HACnt
  401.                 DevTyp.SRB_Target = IDCnt
  402.                 DevTyp.SRB_LUN = LUNCnt
  403.                 SRBGetDev DevTyp
  404.  
  405.                 If DevTyp.SRB_Hdr.SRB_Status = SS_COMP Then
  406.  
  407.                     Debug.Print "ASPI: found device (" & DevTyp.DEV_DeviceType & ")", _
  408.                                 " HA: " & HACnt & " " & _
  409.                                 " ID: " & IDCnt & " " & _
  410.                                 " LUN: " & LUNCnt
  411.  
  412.                     If DevTyp.DEV_DeviceType = DTYPE_CDROM Then
  413.                         colDrives.Add Chr$(HACnt) & Chr$(IDCnt) & Chr$(LUNCnt)
  414.                     End If
  415.  
  416.                 End If
  417.  
  418.             Next
  419.  
  420.         Next
  421.  
  422.     Next
  423. End Sub
  424.  
  425. Private Property Get Iscsi_DriveChar(handle As String) As Variant
  426.     Dim btHA As Byte
  427.     Dim btID As Byte
  428.     Dim btLUN As Byte
  429.  
  430.      btHA = Asc(Mid$(handle, 1, 1))
  431.      btID = Asc(Mid$(handle, 2, 1))
  432.     btLUN = Asc(Mid$(handle, 3, 1))
  433.  
  434.     If IsNT Then
  435.         Iscsi_DriveChar = DriveCharWinNT(btHA, btID, btLUN)
  436.     Else
  437.         Iscsi_DriveChar = DriveCharWin9x(btHA, btID, btLUN)
  438.     End If
  439. End Property
  440.  
  441. Private Property Get ISCSI_DriveCount() As Integer
  442.     ISCSI_DriveCount = colDrives.Count
  443. End Property
  444.  
  445. Private Property Get ISCSI_DriveHandle(index As Integer) As String
  446.     ISCSI_DriveHandle = colDrives.Item(index)
  447. End Property
  448.  
  449. Private Function ISCSI_ExecCMD(ByVal drive As String, _
  450.             cdb() As Byte, _
  451.             CDBLen As Byte, _
  452.             direction As DataDirection, _
  453.             ByVal buffer As Long, _
  454.             ByVal bufferlen As Long, _
  455.             Optional timeout As Integer = 5) As Status
  456.  
  457.     Dim SRB_Exec    As SRB_ExecuteIO
  458.     Dim SRB_Timeout As SRB_GetSetTimeouts
  459.     Dim blnTimeout  As Boolean
  460.     Dim hEvent      As Long
  461.     Dim lngRet      As Long
  462.     Dim btHA        As Byte
  463.     Dim btID        As Byte
  464.     Dim btLUN       As Byte
  465.  
  466.     ' Bus Address
  467.     btHA = Asc(Mid$(drive, 1, 1))
  468.     btID = Asc(Mid$(drive, 2, 1))
  469.    btLUN = Asc(Mid$(drive, 3, 1))
  470.  
  471.     ' Event for scsi status
  472.     hEvent = CreateEvent(0, 1, 0, 0)
  473.     ResetEvent hEvent
  474.  
  475.     With SRB_Exec
  476.         .SRB_Hdr.SRB_Cmd = SC_EXEC_SCSI_CMD
  477.         .SRB_PostProc = hEvent
  478.  
  479.         .SRB_Hdr.SRB_HAID = btHA
  480.         .SRB_Target = btID
  481.         .SRB_LUN = btLUN
  482.  
  483.         .SRB_BufPointer = buffer
  484.         .SRB_BufLen = bufferlen
  485.  
  486.         .SRB_SenseLen = SENSE_LEN
  487.  
  488.         If direction = DIR_IN Then
  489.             .SRB_Hdr.SRB_Flags = SRB_DIR_IN
  490.         Else
  491.             .SRB_Hdr.SRB_Flags = SRB_DIR_OUT
  492.         End If
  493.  
  494.         .SRB_CDBLen = CDBLen
  495.         CopyMemory .SRB_CDBByte(0), cdb(0), CDBLen
  496.     End With
  497.  
  498.     SRBExec SRB_Exec
  499.  
  500.     If Not blnTimeout Then
  501.         ' wait for ever?
  502.         If timeout = 0 Then
  503.             Do While SRB_Exec.SRB_Hdr.SRB_Status = SS_PENDING
  504.                 DoEvents
  505.             Loop
  506.         Else
  507.             ' wait for a specific amount of time for completion
  508.             Sleep 30
  509.             If SRB_Exec.SRB_Hdr.SRB_Status = SS_PENDING Then
  510.                 lngRet = WaitForSingleObject(hEvent, timeout * 1000)
  511.             End If
  512.         End If
  513.     Else
  514.         Do While SRB_Exec.SRB_Hdr.SRB_Status = SS_PENDING
  515.             DoEvents
  516.         Loop
  517.     End If
  518.  
  519.     If blnTimeout Then
  520.         If SRB_Exec.SRB_Hdr.SRB_Status = SS_ABORTED Then
  521.             ISCSI_ExecCMD = STATUS_TIMEOUT
  522.         Else
  523.             ISCSI_ExecCMD = SRB_Exec.SRB_TargStat
  524.         End If
  525.     Else
  526.         If lngRet = WAIT_TIMEOUT And SRB_Exec.SRB_Hdr.SRB_Status <> SS_COMP Then
  527.             ISCSI_ExecCMD = STATUS_TIMEOUT
  528.         Else
  529.             ISCSI_ExecCMD = SRB_Exec.SRB_TargStat
  530.         End If
  531.     End If
  532.  
  533.     btLastSK = SRB_Exec.SRB_SenseData(2) And &HF
  534.     btLastASC = SRB_Exec.SRB_SenseData(12)
  535.     btLastASCQ = SRB_Exec.SRB_SenseData(13)
  536.  
  537.     CloseHandle hEvent
  538. End Function
  539.  
  540. Private Function SRBInq(udt As SRB_HAInquiry) As Long
  541.     SRBInq = ASPILib.CallFunc(FNC_CMD, VarPtr(udt))
  542. End Function
  543.  
  544. Private Function SRBGetDev(udt As SRB_GetDevType) As Long
  545.     SRBGetDev = ASPILib.CallFunc(FNC_CMD, VarPtr(udt))
  546. End Function
  547.  
  548. Private Function SRBDiskInfo(udt As SRB_GetDiskInfo) As Long
  549.     SRBDiskInfo = ASPILib.CallFunc(FNC_CMD, VarPtr(udt))
  550. End Function
  551.  
  552. Private Function SRBExec(udt As SRB_ExecuteIO) As Long
  553.     SRBExec = ASPILib.CallFunc(FNC_CMD, VarPtr(udt))
  554. End Function
  555.  
  556. Private Function SRBSetTimeout(udt As SRB_GetSetTimeouts) As Long
  557.     SRBSetTimeout = ASPILib.CallFunc(FNC_CMD, VarPtr(udt))
  558. End Function
  559.  
  560. Private Property Get ISCSI_HostAdapter(handle As String) As Byte
  561.     ISCSI_HostAdapter = Asc(Mid$(handle, 1, 1))
  562. End Property
  563.  
  564. Private Property Get ISCSI_Initialized() As Boolean
  565.     ISCSI_Initialized = HiByte(LoWord(ASPILib.CallFunc(FNC_INFO))) = SS_COMP
  566. End Property
  567.  
  568. Private Property Get ISCSI_Installed() As Boolean
  569.     ISCSI_Installed = blnASPIInst
  570. End Property
  571.  
  572. Private Sub Class_Initialize()
  573.     Set ASPILib = New clsCDECL
  574.     Set colDrives = New Collection
  575.     blnASPIInst = ASPILib.DllLoad("WNASPI32.DLL")
  576.     FindDrives
  577. End Sub
  578.  
  579. Private Sub Class_Terminate()
  580.     ASPILib.DllUnload
  581. End Sub
  582.  
  583. Private Function IsW2K() As Boolean
  584.     Dim sys As OSVERSIONINFOEX
  585.  
  586.     sys.dwOSVersionInfoSize = Len(sys)
  587.     GetVersionEx sys
  588.  
  589.     If sys.dwPlatformId = VER_PLATFORM_WIN32_NT Then
  590.         IsW2K = sys.dwMajorVersion >= 5
  591.     End If
  592. End Function
  593.  
  594. Private Function IsNT() As Boolean
  595.     Dim sys As OSVERSIONINFOEX
  596.  
  597.     sys.dwOSVersionInfoSize = Len(sys)
  598.     GetVersionEx sys
  599.  
  600.     IsNT = sys.dwPlatformId = VER_PLATFORM_WIN32_NT
  601. End Function
  602.  
  603. Private Function LoWord(ByVal DWord As Long) As Long
  604.   LoWord = DWord And &HFFFF&
  605. End Function
  606.  
  607. Private Function HiWord(ByVal DWord As Long) As Long
  608.   HiWord = (DWord And &HFFFF0000) \ &H10000
  609. End Function
  610.  
  611. Private Function LoByte(ByRef Word As Integer) As Byte
  612.   LoByte = Word And &HFF
  613. End Function
  614.  
  615. Private Function HiByte(ByRef Word As Integer) As Byte
  616.   HiByte = (Word And &HFF00&) \ &H100
  617. End Function
  618.  
  619. Private Property Get ISCSI_Interface() As String
  620.     ISCSI_Interface = "ASPI"
  621. End Property
  622.  
  623. Private Property Get ISCSI_LastASC() As Byte
  624.     ISCSI_LastASC = btLastASC
  625. End Property
  626.  
  627. Private Property Get ISCSI_LastASCQ() As Byte
  628.     ISCSI_LastASCQ = btLastASCQ
  629. End Property
  630.  
  631. Private Property Get ISCSI_LastSK() As Byte
  632.     ISCSI_LastSK = btLastSK
  633. End Property
  634.  
  635. Private Property Get ISCSI_LUN(handle As String) As Byte
  636.     ISCSI_LUN = Asc(Mid$(handle, 3, 1))
  637. End Property
  638.  
  639. Private Property Get ISCSI_TargetID(handle As String) As Byte
  640.     ISCSI_TargetID = Asc(Mid$(handle, 2, 1))
  641. End Property
  642.