Buffer(BUFFER_SIZE) As Byte
Length As Long
Type As Integer
End Type
Const RECV_MAX = 32
Dim RecvTab(RECV_MAX) As PacketTable
Dim EventTab(RECV_MAX) As Long
Dim InBuff(1514) As Byte
Dim OutBuff(1514) As Byte
Function Bind(hVxD As Long, inBuffer As String) As Boolean
Dim hEvent As Long
Dim cbRet As Long
Dim ovlp As OVERLAPPED
Dim result As Long
Dim cbIn As Long
cbIn = 5
hEvent = CreateEvent(0, 1, 0, vbNullString)
If hEvent = 0 Then
Bind = False
MsgBox "err bind"
Exit Function
End If
ovlp.hEvent = hEvent
'((0x8000) << 16) | ((0) << 14) | ((7) << 2) | (0))
Const IOCTL_PROTOCOL_BIND = &H8000001C
result = DeviceIoControlAsString(hVxD, _
IOCTL_PROTOCOL_BIND, _
ByVal inBuffer, _
cbIn, _
ByVal inBuffer, _
cbIn, _
cbRet, _
ovlp)
If (result = 0) Then
Call GetOverlappedResult(hVxD, ovlp, cbRet, True)
End If
Call CloseHandle(hEvent)
Bind = True
End Function
Function QueryPacket(ByVal hVxD As Long, ByVal ioctl As Long, ByVal cbIn As Long, ByVal cbOut As Long) As Long
Dim hEvent As Long
Dim cbRet As Long
Dim ovlp As OVERLAPPED
Dim result As Long
hEvent = CreateEvent(0, 1, 0, vbNullString)
If hEvent = 0 Then
QueryPacket = False
MsgBox "err bind"
Exit Function
End If
ovlp.Internal = 0
ovlp.InternalHigh = 0
ovlp.offset = 0
ovlp.OffsetHigh = 0
ovlp.hEvent = hEvent
' ioc = &H80000018
相關(guān)推薦:2011年上半年計(jì)算機(jī)等級考試報(bào)名時(shí)間匯總
2011計(jì)算機(jī)等級考試二級VB考點(diǎn)及習(xí)題匯總
北京 | 天津 | 上海 | 江蘇 | 山東 |
安徽 | 浙江 | 江西 | 福建 | 深圳 |
廣東 | 河北 | 湖南 | 廣西 | 河南 |
海南 | 湖北 | 四川 | 重慶 | 云南 |
貴州 | 西藏 | 新疆 | 陜西 | 山西 |
寧夏 | 甘肅 | 青海 | 遼寧 | 吉林 |
黑龍江 | 內(nèi)蒙古 |