For Programmers: Free Programming Magazines  


Home > Archive > Clarion > December 2006 > Re: VB6 Conversion Accessing a DLL using CLARION









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: VB6 Conversion Accessing a DLL using CLARION
Michael

2006-12-11, 6:57 pm


clackmannan wrote:
> Michael wrote:
>
> Try this. The most obvious thing wrong with your previous definition
> was the "DIM(60)", unless there's something else you're not telling us
> :)
>
> TstPollRecord Group,Type
> iClassCode Short
> iIllegalCode Short
> cDateTime CString(20)
> cCard CString(20)
> cDeviceID CString(10)
> End ! Group
>
> In Delphi PstPollRecord is declared as "^TstPollRecord" which almost
> certainly means "Pointer to TstPollRecord"
>
> You get the same thing in Clarion by doing
>
> mygroup like(TstPollRecord)
> mypointer ulong
> code
> mypointer = address(mygroup)
>
> Your prototype may or not be correct, I don't know enough about Dephi
> types to know what their CW equivalent is.
>
> If your vendor gave you C versions of the structure & procedure
> definitions then it's normally easier to convert from them, as there's
> more resources available to help you.
>
> HTH,
> Paul


Thanks Paul

the 3rd party has alos provided sample code for VB6

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com