T
taibu
Unregistered / Unconfirmed
GUEST, unregistred user!
程序设计思路如下:主程序调用一个DLL,DLL再调用消费机接口.<br>DLL中函数如下(ReadICCardEx函数为消费机接口函数):<br> function ICCardReadEx(PortHandle: THandle;Var CardNo, CardName, pwd: PChar;var Money, Times,<br> day_consumed, day_times, c_month, c_day, c_flag, GroupStation, GroupId, CardStyle: Integer): Boolean; stdcall;<br>var<br> CardBuf, NameBuf,PwdBuf: array[1..50] of char; <br> Str1,Str2,Str3:String;<br>begin<br> FillChar(CardBuf, SizeOf(CardBuf), 0);<br> FillChar(NameBuf, SizeOf(NameBuf), 0);<br> FillChar(PwdBuf, SizeOf(PwdBuf), 0);<br> Result:=ReadICCardEx(PortHandle,@CardBuf, @NameBuf, @PwdBuf,Money,Times,Day_Consumed,Day_Times,C_Month,C_Day,C_Flag,GroupStation,GroupId,CardStyle);<br> Str1:=CardBuf;<br> Str2:=NameBuf;<br> Str3:=PwdBuf;<br> CardNo:=Pchar(Str1);<br> CardName:=Pchar(Str2);<br> PWd:=Pchar(Str3);<br>end;<br><br>主程序调用代码如下:<br><br>var<br> DllHandle:THandle;<br> Dllfarproc:Tfarproc;<br> CommuPort:String;<br> Port,BaudRate,Clockid:Integer;<br> RstCon:Integer;<br> DllFile:String;<br><br> Money, Times, Ver, GroupStation, GroupId, block: Integer;<br> day_consumed, day_times, c_month, c_day, c_flag: Integer;//ER-690卡扩展参数<br> CardNo, CardName,CardPwd: Pchar;<br> sCardNo,sCardName,sCardPwd:String;<br>begin<br> .......//其它代码未贴出<br><br> Dllfarproc:=GetProcAddress(DllHandle,'ICCardReadEx'); //获取函数入口<br> if DllfarProc<>Nil then<br> if ICCardReadExDll(Dllfarproc)(RstCon,CardNo,CardName,CardPwd,Money,Times,Day_Consumed,Day_Times,C_Month,C_Day,C_Flag,GroupStation,GroupId,Ver) then<br> begin<br> sCardNo:=StrPas(CardNo); //奇怪的问题在这里,未执行该行前,CardNo='00111',一执行完后,sCardNo及CardNo的值为'0011',这是为什么?<br> sCardName:=StrPas(CardName); //奇怪<br> sCardPwd:=StrPas(CardPwd);