|
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 ;
pparams=^TParams;
var
Form1: TForm1;
implementation
{$R *.dfm}
function OpenComm(var lParam:pParams;sType:Integer): Integer;stdcall; external 'CM60.dll' ;
function CloseComm(var lParam:pParams;sType:Integer): Integer;stdcall; external 'CM60.dll';
procedure TForm1.Button1Click(Sender: TObject);
var
p:pparams;
sType, ret: Integer;
begin
sType :=2100;
p.Port :='001';
p.CtrlID :='001';
ret := OpenComm(p,sType);
showmessage(inttostr(ret));
ret := CloseComm(p, sType);
p.CtrlID :='';
showmessage(inttostr(ret));
end;
end.
编辑成功,运行的时候 p.Port :='001';
p.CtrlID :='001';出现存取地址错误 |
|