|
考勤机动态库说明:
说明:所有函数只接受两个参数
参数一:Params结构
参数二:表示硬件类型的数值, 取值[30, 60, 2000, 2100, 2200, 2300, 2600]
Params结构定义
Public Type Params
Port As String * 3 //串口号,[1~255]
CtrlID As String * 3 //设备号,[1~127]
Params As String * 1024 //输入:传递给设备处理的参数表,多参数间以分号分隔,以分号结束
//输出:接口返回值
End Type
接口返回值定义
100 //调用接口失败
101 //不支持该类型设备
102 //该设备不支持该接口
103 //设备无响应
104 //参数错误
105 //调用成功
106 //串口没打开
107 //打开文件错误
108 //通讯参数错误,要求重发
109 //返回值数据校验错误
110 //创建线程错误
111 //设备忙
一. IT2100
1. 打开串口
声明
Public Declare Function OpenComm Lib "CM60.dll" (ByRef lParam As Params, ByVal sType As Integer) As Integer
调用例子
dim p as Params
dim sType as Integer
dim ret as Long
sType = 2100
p.Port = “001” ‘打开串口一
p.CtrlID = “001” ‘设备号为1
ret = OpenComm(p, sType)
select case ret
case 100 ‘打开失败
case 105 ‘打开串口成功
case else
end select
我测试:
unit Ukq;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TParams = Record
Port: String[3];
CtrlID: String[3]; //设备号,[1~127]
Params: string[250];
end ;
var
Form1: TForm1;
implementation
{$R *.dfm}
function OpenComm(var lParam:tParams;sType:Integer): Integer;stdcall; external 'CM60.dll' ;
function CloseComm(var lParam:tParams;sType:Integer): Integer;stdcall; external 'CM60.dll';
procedure TForm1.Button1Click(Sender: TObject);
var
p: TParams;
sType, ret: Integer;
begin
sType := 2100;
p.Port :=edit1.text;
p.CtrlID :=edit2.Text;
ret := OpenComm(p, sType);
showmessage(inttostr(ret));
ret := CloseComm(p, sType);
p.CtrlID :='';
showmessage(inttostr(ret));
end;
end.
打开串口和关闭串口都是返回100(调用串口失败),而用考勤机自己的终端管理是可以打开第1,2个串口的,不知道是不是我的测试程序有问题
|
|