| Michael 2006-12-11, 6:57 pm |
| Hi all,
Help !! Help !!!
I am trying to use a 3rd party DLL, the 3rd party has provided sample
code for VB V6.
In VB the following is defined.
Public Type poll
iClassCode As Integer ' //Class Code
iIllegalCode As Integer ' //Illegal Code
sDate As String
sCard As String
sDeviceID As String
' sReader As String
End Type
Declare Function htaPolling Lib "HTA8.dll" (ByVal hComm As Integer,
ByVal inodeid As Integer, ByVal iprevRecord As Integer, ByRef stRecord
As Byte, _
ByRef irecord As Integer, ByVal icardtype As
Integer, ByVal itimeout As Integer) As Integer
' htaPolling (HANDLE hComm,int iNodeID,int iPrevRecord,stPollList
*stRecord,
' int *iRecord,int
iCardType,unsigned int iTimeout);
Function polling(ByVal inodeid As Integer, ByVal icardtype As Integer)
As Boolean
Dim vPoll As Integer
Dim iRec As Integer
Dim flag As Boolean
Dim i As Integer
Dim j As Integer
Dim k As Long
Dim sEvnetCode As String
Dim IllegalCode As String
Dim sDate As String
Dim sCard As String
Dim sDeviceID As String
Dim l As String
Dim bAa() As Byte
ReDim bAa(255 * 60)
vPoll = htaPolling(rltcom, inodeid, iprevR(inodeid), bAa(0),
iRec, icardtype, 1000)
If vPoll = 0 Then
iprevR(inodeid) = iRec
Text1.Text = "polling is success!"
For i = 0 To iRec - 1
sEvnetCode = "Class Code: "
For j = 3 To 0 Step -1
sEvnetCode = sEvnetCode & Trim(Str(bAa(i * 60 +
j)))
Next j
IllegalCode = "legal Code:"
For j = 7 To 4 Step -1
IllegalCode = IllegalCode & Trim(Str(bAa(i * 60
+ j)))
Next j
sDate = "Date time: "
For j = 8 To 27
If (Asc(Chr(bAa(i * 60 + j))) > 0) Then
sDate = sDate & Chr(bAa(i * 60 + j))
End If
Next j
sCard = "Card NO: "
For j = 28 To 47
If (Asc(Chr(bAa(i * 60 + j))) > 0) Then
sCard = sCard & Chr(bAa(i * 60 + j))
End If
Next j
sDeviceID = "Device ID: "
For j = 48 To 57
If (bAa(i * 60 + j) > 0) Then
sDeviceID = sDeviceID & Chr(bAa(i * 60 + j))
End If
Next j
l = sEvnetCode & " " & sDate & " " & sCard & " " &
sDeviceID & " " & IllegalCode
List1.AddItem l
Next i
flag = True
ElseIf rltcom <> 0 Then
If vPoll = 1010 Then
Text1.Text = "The HTA" + Trim(Str(inodeid)) + " has not
data!"
flag = True
Else
Text1.Text = "Polling the HTA" + Trim(Str(inodeid)) + " is
failure!"
End If
Else
Text1.Text = "Polling the HTA" + Trim(Str(inodeid)) + " is
failure!"
flag = False
End If
polling = flag
End Function
Private Sub btnpolling_Click()
Dim vPoll As Integer
Dim flag As Boolean
Dim iRec As Integer
Dim i As Integer
Dim j As Integer
Dim icardtype As Long
Dim l As String
If Check7.Value = 1 Then
icardtype = 1
Else
icardtype = 0
End If
If Check1.Value = 1 Then
flag = polling(1, icardtype)
End If
If Check2.Value = 1 Then
flag = polling(2, icardtype)
End If
If Check3.Value = 1 Then
flag = polling(3, icardtype)
End If
If Check4.Value = 1 Then
flag = polling(4, icardtype)
End If
If Check5.Value = 1 Then
flag = polling(5, icardtype)
End If
If Check6.Value = 1 Then
flag = polling(6, icardtype)
End If
End Sub
http://groups.google.com/group/comp...e743f2b2f?hl=en
|