dll的窗体上写的函数如下:
function opencomm(scomm:string):LongBool;
begin
try
comm1.CommName:=scomm;
Comm1.StartComm;
messagedlg('打开'+scomm+'串口成功!',mtinformation,[mbyes],0);
Result:=true;
except
messagedlg('打开'+scomm+'串口时失败,可能该串口已被占用或不存在,请换另一个串口!',mterror,[mbyes],0);
Result:=false;
end;
end;我用另一个程序来调用该dll的窗体上的上述函数时,却发现:
comm1.CommName:=scomm;
Comm1.StartComm;
这两条指令不能执行,请问是怎么原因呀?
调用的过程为:
procedure TFCOMM.btnopenClick(Sender: TObject);
begin
opencomm('COM1');
end;请各位大虾指点,谢谢。
function opencomm(scomm:string):LongBool;
begin
try
comm1.CommName:=scomm;
Comm1.StartComm;
messagedlg('打开'+scomm+'串口成功!',mtinformation,[mbyes],0);
Result:=true;
except
messagedlg('打开'+scomm+'串口时失败,可能该串口已被占用或不存在,请换另一个串口!',mterror,[mbyes],0);
Result:=false;
end;
end;我用另一个程序来调用该dll的窗体上的上述函数时,却发现:
comm1.CommName:=scomm;
Comm1.StartComm;
这两条指令不能执行,请问是怎么原因呀?
调用的过程为:
procedure TFCOMM.btnopenClick(Sender: TObject);
begin
opencomm('COM1');
end;请各位大虾指点,谢谢。
需要吗???
withcsharp() 还有什么好的方法吗?
可以详细的说一下吗?
先谢了。
library Project1;
uses
SysUtils,
Classes,
COMM in 'COMM.pas' {FCOMM};{$R *.res}
exports
showmyForm,opencomm;
begin
end.
我的函数opencomm就是放在comm.pas里的。
spcomm控件就是放在comm.dfm上面的。