unit Dll_Use_Test;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,MSCommLib_TLB, OleCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
{$IfNdef Mydll}
Function Rf_Check_Port(MsComm:TMsComm;Var sReadData:WideString):Integer; StdCall;
Function Send_Ok(MSComm:TMSComm;bz:Integer):Integer;StdCall;
Function Rf_TestComm(MsComm:TMsComm):Integer; StdCall;//;External 'MyDll.Dll' Name 'Rf_TestComm'; {$EndIf}
var
Form1: TForm1;
MsComm1:TmsComm;
CurMsComm1:TMsComm;
implementation
// Uses Un_Dll;{$R *.dfm}
{$ifndef MyDll}
Function Rf_Check_Port;External 'MyDll.Dll' Name 'Rf_Check_port';
Function Rf_TestComm;External 'MyDll.Dll' Name 'Rf_TestComm';
Function Send_Ok;External 'MyDll.Dll' Name 'Send_Ok';{$endIf}
procedure TForm1.Button1Click(Sender: TObject);
Var
settings:String;
SreadData,SData:WideString;
begin
Settings:=IntToStr(9600)+',n,8,1';
CurMsComm1:=TMSCOMM.Create(Application);
CurMsComm1.CommPort:=1;
CurMsComm1.InputMode:=1;
CurMsComm1.Settings:=Settings;
If not CurMsComm1.PortOpen Then
CurMsComm1.PortOpen:=true;
send_ok(CurMscomm1,9);
Sleep(100);
Rf_TestComm(CurMsComm1); RF_Check_Port(CurMsComm1,SReadData);
// showmessage(sreadData);
CurMscomm1.PortOpen:=false;
end;end.
编译时提示
无法定位程序输入点Rf_Check_Port于动态链接库MyDll.Dll上。
请问是什么问题?谢谢!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,MSCommLib_TLB, OleCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
{$IfNdef Mydll}
Function Rf_Check_Port(MsComm:TMsComm;Var sReadData:WideString):Integer; StdCall;
Function Send_Ok(MSComm:TMSComm;bz:Integer):Integer;StdCall;
Function Rf_TestComm(MsComm:TMsComm):Integer; StdCall;//;External 'MyDll.Dll' Name 'Rf_TestComm'; {$EndIf}
var
Form1: TForm1;
MsComm1:TmsComm;
CurMsComm1:TMsComm;
implementation
// Uses Un_Dll;{$R *.dfm}
{$ifndef MyDll}
Function Rf_Check_Port;External 'MyDll.Dll' Name 'Rf_Check_port';
Function Rf_TestComm;External 'MyDll.Dll' Name 'Rf_TestComm';
Function Send_Ok;External 'MyDll.Dll' Name 'Send_Ok';{$endIf}
procedure TForm1.Button1Click(Sender: TObject);
Var
settings:String;
SreadData,SData:WideString;
begin
Settings:=IntToStr(9600)+',n,8,1';
CurMsComm1:=TMSCOMM.Create(Application);
CurMsComm1.CommPort:=1;
CurMsComm1.InputMode:=1;
CurMsComm1.Settings:=Settings;
If not CurMsComm1.PortOpen Then
CurMsComm1.PortOpen:=true;
send_ok(CurMscomm1,9);
Sleep(100);
Rf_TestComm(CurMsComm1); RF_Check_Port(CurMsComm1,SReadData);
// showmessage(sreadData);
CurMscomm1.PortOpen:=false;
end;end.
编译时提示
无法定位程序输入点Rf_Check_Port于动态链接库MyDll.Dll上。
请问是什么问题?谢谢!
请确定这一点。还有就是你用了name话,那"Rf_Check_port"需要和dll中导出函数的名称绝对匹配才行。建议你不要加name,虽然调用速度快(寻找到对应的函数快),但如果不吻合那就要出错。
对的!我的MyDll.Dll和EXE文件在一个目录下。
我去看看!