unit DLLInterface;
interface
Type
INITTBL = record
speed :LongInt;
length:LongInt;
parity:LongInt;
sbit :LongInt;
ptout :longInt;
ctout :longInt;
cretry:LongInt;
stopkey1:LongInt;
stopkey2:LongInt;
End;
Type
CINFTBL = record
htid :String[6];
htdmy:String[2];
dav :LongInt;
fileno : LongInt;
filesize :LongInt;
jobcmd :LongInt;
datatype :LongInt;
End;
function hst_open(chno:LongInt; var _inittbl:INITTBL):Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_idtblclr:Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_idtbladd(iddata:string):Integer cdecl {$IFDEF WIN32} stdcall {$EndIF};
//function hst_open(chno : LongInt; var _initab : INITTBL) : Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_close: Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_polling (var recno : LongInt; ioboxno : LongInt) : Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_idtblgetidno : Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_getcinffirst(var inftab : CINFTBL): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_getcinfnext(var inftab : CINFTBL) : Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_filerecv(pname : String; var inftab : CINFTBL) : Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_filesend(pname : String; var inftab : CINFTBL) : Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_disconnect(mode : LongInt; var inftab : CINFTBL) : Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_idtblgetid(recno : LongInt; iddata : String) : Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
function hst_sethwnd(chno:LongInt; var recno:LongInt):Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};
var
_INITTBL:INITTBL;
_CINFTBL:CINFTBL;
implementation
function hst_open; external 'hostcm32.dll';
function hst_idtblclr; external 'hostcm32.dll';
function hst_idtbladd; external 'hostcm32.dll';
// function hst_open;external 'hostcm32.dll';
function hst_close;external 'hostcm32.dll';
function hst_polling;external 'hostcm32.dll';
function hst_idtblgetidno;external 'hostcm32.dll';
function hst_getcinffirst;external 'hostcm32.dll';
function hst_getcinfnext;external 'hostcm32.dll';
function hst_filerecv;external 'hostcm32.dll';
function hst_filesend;external 'hostcm32.dll';
function hst_disconnect;external 'hostcm32.dll';
function hst_idtblgetid;external 'hostcm32.dll';
function hst_sethwnd;external 'hostcm32.dll';
end.
unit pasMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses DLLInterface;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a, b:Integer;
recno:LongInt;
begin
_INITTBL.speed := 4;
_INITTBL.length := 0;
_INITTBL.parity := 0;
_INITTBL.sbit := 1;
_INITTBL.ptout := 100;
_INITTBL.ctout := 1000;
_INITTBL.cretry := 99;
_INITTBL.stopkey1 := 2;
_INITTBL.stopkey2 := 0;
_CINFTBL.jobcmd := 0;
_CINFTBL.htid:='&&&&&&';
If hst_open(2,_INITTBL)<>0 Then
Begin
MessageBox(Handle,'端口打开失败!','系统提示',64);
Abort;
End;
recno := 0;
a:=hst_polling(recno,3);
Showmessage(inttostr(a));
hst_close();
end;
end.