考勤机的动态库调用说明是vb的
说明:所有函数只接受两个参数
参数一: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
1。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
2。2. 关闭串口
声明
Public Declare Function CloseComm 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=”” ‘设备号忽略
ret=CloseComm(p,sType)
select case ret
case 100 ‘关闭串口一失败
case 105 ‘关闭串口一成功
case else
end select
请问1,2两个示例在delphi中如何调用?
说明:所有函数只接受两个参数
参数一: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
1。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
2。2. 关闭串口
声明
Public Declare Function CloseComm 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=”” ‘设备号忽略
ret=CloseComm(p,sType)
select case ret
case 100 ‘关闭串口一失败
case 105 ‘关闭串口一成功
case else
end select
请问1,2两个示例在delphi中如何调用?
解决方案 »
- 请教问题
- 数据集中的字段值问题
- 关于SDAC的问题
- 请教delphi 7.0问题
- Delphi连接Access,哪种方式是最通用的?也就是说别人拿到这个软件,不用装各种数据库驱动
- To 海天子我是调用你说的函数进行转换,但是有这样的一个问题,在画图中打开一幅图片,在不同的分辨率下,它的像素点数和英寸不变,但厘
- 兄弟们,我要模拟频谱仪的波形变化,请问用什么控件比较好??
- 请问DBGRID怎么去掉自己不想要的部分字段呢
- WINDOWS7
- 在foxpro中要想查ID在61000到65000之间的数据,用between怎么用?
- 请问:货币转换程序中的变量qianwei是如何起判断作用?
- 文本删除重复算法问题~~高手请指点下(keyz在吗 )
type
TParams = Record
Port: String[3]
CtrlID: String[3] //设备号,[1~127]
Params: String[1024]
end
//函数声明
function OpenComm(var lParam: Params, sType: Integer): Integer; external CM60.dll name 'OpenComm';
function CloseComm(var lParam: Params, sType: Integer): Integer; external CM60.dll name 'CloseComm';//调用:
var
p: TParams;
sType, ret: Integer;
begin
sType := 2100;
p.Port := '001';
p.CtrlID := '001';
ret := OpenComm(p, sType);
case ret of
100: ShowMessage('打开失败');
105: ShowMessage('打开串口成功');
end;
p.Port := '001';
p.CtrlID := '';
ret := CloseComm(p, sType);
case ret of
100: ShowMessage('失败');
105: ShowMessage('成功');
end;
end;
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.