Code as shown in the following, in the part of the Windows 7 system directly prompt card failure, external components an exception occurs, add all breakpoints cannot show, during the breakpoint added nine, but the cancellation of part of the code can prompt the cancellation of success
Exclude hope too did the operating system or in a computer can solve by changing the program code to solve
Thank you very much!
The unit UProUSB;
Interface
USES the
Dialogs,
UDllFun,
Windows,
SysUtils,
Classes,
DateUtils,
Inifiles,
StrUtils;
Const
='proRFL dllname66. DLL';
ReadCard66='ReadCard';
WriteCard66='GuestCard';
CancelCard66='CardErase';
OpenPort66='initializeUSB';
ClosePort ClosePort66=' ';
Buzzer Buzzer66=' ';
ReadRoomNo='GetGuestLockNoByCardDataStr';
ReadTime='GetGuestETimeByCardDataStr';
Type
TinitializeUSB66=function (fUSB: Byte) : integer; Stdcall;
TReadCard66=function (fUSB: Byte; Buffer: PChar) : integer; Stdcall;
TGuestCard66=function (fUSB: Byte; DlsCoID: Integer; CardNo, dai, llock pdoors: Byte; BDate, EDate, RoomNo: Pchar; CardHexStr: PChar) : integer; Stdcall;
TCardErase66=function (fUSB: Byte; DlsCoID: Integer; CardHexStr: PChar) : Integer; Stdcall;
TClosePort66=function (hCommDev: Integer) : Integer; Stdcall;
TBuzzer66=function (fUSB: Byte; T: Integer) : Integer; Stdcall;
TGetGuestLockNoByCardDataStr=function (dlsCoID: Integer; CardHexStr LockNo: PChar) : integer; Stdcall;
TGetGuestETimeByCardDataStr=function (dlsCoID: Integer; CardHexStr LockNo: PChar) : integer; Stdcall;
The function opennewcom66 (port: pchar) : integer; Stdcall;
The function Readserver66 (var st, et: pchar) : Tparm; Stdcall;
The function writeserver66 (parm: Tparm) : integer; Stdcall;
The function Cancelserver66 () : a Boolean; Stdcall;
The function closecom66 () : integer; Stdcall;
Implementation
USES the
UDMdll;
Var
Handle66: Thandle;
FlagUSB: integer;
The function opennewcom66 (port: pchar) : integer; Stdcall;
Var
RefinitializeUSB66: TinitializeUSB66;
Ret: integer;
The begin
OpennewCom66:=0;
Handle66:=loadlibrary (dllname66);
FlagUSB:=1;//0 means have drive, USB, 1 said proUSB
If handle66 & gt; 32 then
The begin
RefinitializeUSB66:=GetProcAddress call (handle66 OpenPort66);
Ret:=refinitializeUSB66 (flagUSB);
If ret & lt;> 0 Then
Showmessage (' open USB failure);
The end;
The end;
The function Readserver66 (var st, et: pchar) : Tparm; Stdcall;//read card section
Var
RefReadCard66: TReadCard66;
RefGetGuestLockNoByCardDataStr: TGetGuestLockNoByCardDataStr;
RefGetGuestETimeByCardDataStr: TGetGuestETimeByCardDataStr;
Ret, coID: integer;
StrInfo: an array of char [0.. 128];
Strdata: string;
LockNo ETime: Array [0.. 16] of char;
The begin
Readserver66. RoomNo:=1;
Readserver66. CardNo:=1;
Readserver66. STime:=' ';
Readserver66. Etime:=' ';
Readserver66. DATA:=' ';
Readserver66. BuildNo:=1;
Readserver66. FloorNo:=1;
Readserver66. Port:=1;
CoID:=strtoint (' 16711829 ');
Try
CoID:=strtoint (' 75162 ');
If handle66 & gt; 32 then
The begin
RefReadCard66:=GetProcAddress call (handle66 ReadCard66);
Ret:=refReadCard66 (flagUSB strInfo);
If ret<> 0 then
The begin
Showmessage (' reading card failure! ');
Readserver66. RoomNo:=1;
Strcopy (st, 'the 1900-01-01 00:00);
Strcopy (et, 'the 1900-01-01 00:00);
Readserver66. Port:=1;
End
Else if leftstr strInfo, (6) & lt;> '551501' then
The begin
Showmessage (' induction zone no card ');
Strcopy (st, 'the 1900-01-01 00:00);
Strcopy (et, 'the 1900-01-01 00:00);
End
The else
The begin
Strdata:=strpas (strInfo);
RefGetGuestLockNoByCardDataStr:=GetProcAddress call (handle66 ReadRoomNo);
Ret:=refGetGuestLockNoByCardDataStr (coID, strInfo LockNo);
Readserver66. RoomNo:=strtoint (midstr (LockNo, 4, 3));
Strcopy (st, 'the 1900-01-01 00:00);
RefGetGuestETimeByCardDataStr:=GetProcAddress call (handle66, ReadTime);
Ret:=refGetGuestETimeByCardDataStr (coID, strInfo ETime);
If ret=0 then
StrPcopy (et, convertDate (pchar (strpas (ETime))))
The else
Strcopy (et, 'the 1900-01-01 00:00);
The end;
End
The else
The begin
Strcopy (st, 'the 1900-01-01 00:00);
Strcopy (et, 'the 1900-01-01 00:00);
The end;
The finally
The end;
The end;
The function writeserver66 (parm: Tparm) : integer; Stdcall;//write card section
Var
RefReadCard66: TReadCard66;
RefGuestCard66: TGuestCard66;
RefBuzzer66: TBuzzer66;
Buildno floorno, roomno: pchar;
I: integer;
CoID: Integer;
CardNo: Integer;
LockNo: an array of char [0.. 8];
Stime eTime: array [0.. 10] of char;
Dai, Doors, LLock: Byte;
CardHexStr: an array of char [0.. 128];
Ret: integer;
StrInfo: an array of char [0.. 128];
The begin
Showmessage (' 1 ');//breakpoint 1
Writeserver66:=1;
Showmessage (' 2 ');//breakpoint 2
Buildno:=StrAlloc (3);
Floorno:=StrAlloc (3);
Roomno:=StrAlloc (4);
CoID:=strtoint (' 67255 ');
Showmessage (' 3 ');//breakpoint 3
CardNo:=0;
Dai:=0;
Doors:=0;
LLock:=1;
Try
Showmessage (' 4 ');//breakpoint 4
If handle66 & gt; 32 then
Showmessage (inttostr (handle66));//breakpoint 5
The begin
The begin
Ret:=0;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull