Home > Back-end >  This DLL call for help: how to write in DELPHI?
This DLL call for help: how to write in DELPHI?

Time:10-01

DLL is written by C, function description is:
Int SDK_KPReadGuestCard (LPSTR p_csRoomNo, LPSTR p_csStartTime, int & amp; P_nTimeUnit, int & amp; P_nTimeLength, int & amp; P_nStopFlag, LPSTR p_csCardNo);

Example is the VB, reference is
Public Declare Function SDK_KPReadGuestCard Lib "KPLOCKSDK. DLL" (ByVal p_csRoomNo $, ByVal p_csStartTime $, ByRef p_nTimeUnit As Long, ByRef p_nTimeLentgh As Long, ByRef p_nStopFlag As Long, ByVal p_csCardNo $) As Long

But because I don't have a VB, also don't know whether sample is correct,

I use the DELPHI call statement is:

The Function SDK_KPReadGuestCard (p_csRoomNo: PCHAR; P_csStartTime: PCHAR; Var p_nTimeUnit: longint; Var p_nTimeLength: longint;
Var p_nStopFlag: longint; P_csCardNo: PCHAR) : LongInt; Stdcall; External 'KPLOCKSDK. DLL';

Call the process is:
Var
StrCardSn: an Array Of Char [0.. 64];
StrRoomNo: an Array Of Char [0.. 64];
StrStartTime: an Array Of Char [0.. 64];
StrInfo: String;

ITimeCount: longint;
ITime: longint;
ILost: longint;

The Begin
Ret:=SDK_KPReadGuestCard (StrRoomNo StrStartTime, iTimeCount, iTime, iLost, StrCardSn);
If Ret & lt;> 1 Then
The Begin
Result:=Pchar (CheckErr (Ret));
exit;
The End;
end;

But the memory after the wrong operation, estimation is my reference is wrong, but many have failed, try and shameless ah, 100 points, online waiting for,

CodePudding user response:

The Function SDK_KPReadGuestCard (p_csRoomNo: PCHAR; P_csStartTime: PCHAR; Var p_nTimeUnit: longint; Var p_nTimeLength: longint;
Var p_nStopFlag: longint; P_csCardNo: PCHAR) : LongInt; Stdcall; External 'KPLOCKSDK. DLL';

String should be no problem, but this should define the integer has a problem, it is also a pointer, use PInteger type instead of

The Function SDK_KPReadGuestCard (p_csRoomNo: PCHAR; P_csStartTime: PCHAR; P_nTimeUnit: PInteger; _nTimeLength: PInteger; P_nStopFlag: PInteger; P_csCardNo: PCHAR) : LongInt; Stdcall; External 'KPLOCKSDK. DLL';

When call

Define PInteger pointer
ILength: ^ Integer;

Use the
SDK_KPReadGuestCard (... , @ iLength,... );

CodePudding user response:

Look at your statement as if no problem, but p_csRoomNo seems to be initialized to a room number, go in for function.
You don't seem to have to the initial value.

CodePudding user response:

The Function SDK_KPReadGuestCard (p_csRoomNo: PCHAR; P_csStartTime: PCHAR; Var p_nTimeUnit: longint; Var p_nTimeLength: longint;
Var p_nStopFlag: longint; P_csCardNo: PCHAR) : LongInt; codecl ; External 'KPLOCKSDK. DLL';

CodePudding user response:

Ret:=SDK_KPReadGuestCard (StrRoomNo StrStartTime, iTimeCount, iTime, iLost, StrCardSn);
Change the
Ret:=SDK_KPReadGuestCard (StrRoomNo StrStartTime, integer (@ iTimeCount), integer (@ iTime), integer (@ iLost), StrCardSn);
& In C is a reference type, belongs to the address class,
  • Related