| 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 Delphi V7.
In Delphi the following is defined.
type
PstPollRecord=^TstPollRecord;
TstPollRecord=record
iClassCode:Integer; //Class Code
iIllegalCode:Integer; //Illegal Code
cDateTime:array[0..19] of Char; //Date Time
cCard:array[0..19] of Char; //Card Number
cDeviceID:array[0..9] of Char; //Device ID
end;
//Send Polling To HTA
function
htaPolling(hComm:THandle;iNodeID,iPrevRe
cord:Integer;stPollList:PstPollRecord;va
r
iRecord:Integer;iCardType:Integer;iTimeO
ut:DWORD):Integer;stdcall;external
'HTA8.dll';
Clarion Equivalent:my strut is declared as:
! in Global Data Defention
PstPollRecord GROUP,PRE()
TstPollRecord GROUP,TYPE,PRE(),DIM(60)
iClassCode SHORT
iIllegalCode SHORT
cDateTime CSTRING(20)
cCard CSTRING(20)
cDeviceID CSTRING(10)
END
END
In Clarion I prototyped my function as:
htaPolling (UNSIGNED hComm, SHORT iNodeID, SHORT giPrevRecord,
*PstPollRecord stPollList, *SHORT iRecord, SHORT iCardType, USHORT
iTimeOut), SHORT,PASCAL,RAW
The problem I cant received data in proper way, the solution I think in
data structure, any help Please!....
Thanks !
Michael
In Delphi the Code as following:
(***************************************
****************************************
Function: TfrmHTADemo.btnhtaPollingClick
Description: NONE
Input: Sender: TObject
Output: NONE
Others: NO
****************************************
***************************************)
procedure TfrmHTADemo.btnhtaPollingClick(Sender: TObject);
var
iRecord,i:Integer;
cBuf:array[0..1024] of Char;
stPollList:PstPollRecord;
begin
pnlCommand.Enabled:= False;
btnhtaPolling.Enabled:= False;
try
stPollList:= @cBuf[0];
for i:= 0 to chklstPolling.Items.Count-1 do
begin
if chklstPolling.Checked[i] then
begin
//must to polling data
FillChar(cBuf,SizeOf(cBuf),0);
iResult:=
htaPolling(hComm,i+1,giPrevRecord[i],stP
ollList,iRecord,Integer(chkCompress.Checked),iTimeOut-2000);
if iResult=htaSuccess then
begin
giPrevRecord[i]:= iRecord;
//'htaPolling OK. ID:'+inttostr(i+1)+' Reutrn:'+
ShowInfo(
' Class
Code:'+inttohex(stPollList.iClassCode,4)+
'
DateTime:'+strpas(stPollList.cDateTime)+
' Card Number:'+strpas(stPollList.cCard)+
' Device
ID:'+strpas(stPollList.cDeviceID)+
' Legal
Code:'+inttohex(stPollList.iIllegalCode,4)
);
Application.ProcessMessages;
end
else
begin
//Maybe No Data.
//must Continue Next Device
//so Cann't Exit and show any Error msg.
//ShowInfo('htaPolling Failed, ID:'+inttostr(i+1)+'
Msg:'+GetErrorDes(iResult));
//Exit;
end;
end;
end;
finally
pnlCommand.Enabled:= True;
btnhtaPolling.Enabled:= True;
end;
end;
procedure TfrmHTADemo.FormCreate(Sender: TObject);
begin
FillChar(giPrevRecord,sizeof(giPrevRecor
d),0);
end;
procedure TfrmHTADemo.pnlNormalCmdClick(Sender: TObject);
begin
//
end;
|