关于开钱箱(不是用螺丝刀子开)

//开钱箱:桑达CR3000A的QXDLL.dll有两个外部接口:opend(int t1,int t2,unsigned port)。其中t1,t2分别为延时t1,t2毫秒;port为十六进制的
//端口地址。实现的功能是先往该端口送数据7,然后延时t1毫秒,再送数据0,然后再延时t2毫秒。
Function OpenMoneyBoxCR3000(nInPortAddress:integer=-1):Boolean;
type _openCr3K=function (t1,t2,port:integer):integer; stdcall; //External 'qxdll.dll' Name 'opend' ;
Var H:tHandle; P:tFarProc; V:TOsVersionInfoA; s:String;
Begin
Result:=False;
Try
V.dwOSVersionInfoSize:=SizeOf(TOsVersionInfoA);
If Not GetVersionEx(V) then Exit;
if V.dwPlatformId>=Windows.VER_PLATFORM_WIN32_NT then s:='cr3000nt.dll' else s:='cr30009X.dll';
if not GetDynaDllProc(s, 'opend',H,P) then Begin
Messagebox(0,'调用开钱箱opend部分出错!终止','OpenMoneyBoxCR3000.openD Error',32);
Exit;
End;
Result:=_openCr3K(p)(500, 500, nInPortAddress)=0;
Finally
FreeLibrary(H);
End;
end;
//开钱葙
Function OpenMoneyBox(sMoneyBoxPort:String; nPortAddress:integer=0):Boolean;
Var PrnFileName: TextFile;
Begin
Result:=False;
Try
if trim(upperCase(sMoneyBoxPort))='CR3000' then begin //桑达CR3000A
result:=openMoneyBoxCr3000(nPortAddress);
exit;
end;
//
Try
Assignfile(PrnFileName,sMoneyBoxPort);
Rewrite(PrnFileName);
//
Write( PRNFileName, sMoneyBoxOpenCommand );
//
Result:=True;
Finally
Try CloseFile(PRNFileName) Except End;
End;
Except
On x:Exception do
Raise Exception.Create('[OpenMoneyBox]开钱箱'+sMoneyBoxPort+'出错!请检查连接,没有钱箱请将系统设置的“钱箱接口”选择成空的。'#13+x.message);
End;
End;

 

posted @ 2016-02-25 16:19  海宏软件  阅读(490)  评论(0编辑  收藏  举报