运行DLL时,总是出现这句'Cannot debug project unless a host application is defined use the run|paramters..dialog box.'这是怎么回事呢??
解决方案 »
- 安装delphi2009时出现invalid serial number错误
- 用Delphi怎么实现禁止访问某些非法网站?
- 动态加载菜单
- 简单问题:C++中的while(!ADOQuery->Eof){}在delphi中如何表示?
- dsgnintf是虾米东西哟
- 好多贴都结不了,因为没有回复。现在强制结贴,信誉分是直线下降,唉。
- 数据远程传送问题
- 实现c中的用法。
- 安装delphi7了,好多控件没法用呀。谁知道rxlib for delphi7出来了没有,在哪里下载?
- 如何模仿NT的登录方式?(特急)
- 请教,我用的是RichEdit控件 ,我怎么样把它存成纯文本格式?急。
- ADOquery与ACCESS数据库的问题!!!
RUN->Parameters->在Host Application 中输入你要调用的主程序EXE 文件
如果要调试 应该先 run->paramters 来关联一可执行文件,之后在点Run 就可以了
var
tmpF: procedure(const MyHandle:THandle);
tmpHandle: Thandle;
begin
tmpHandle := LoadLibrary(Pointer(dllPath));
if tmpHandle<>0 then
try
begin
@tmpF := GetProcAddress(tmpHandle,pointer(functinName));
if (@tmpF<>nil) then tmpF(Application.Handle);
end;
finally
FreeLibrary(tmpHandle);
end;
end;这是我自己的代码,参考下。
var TmpForm : TCustomerOrderList;
tmpHandle: THandle;
begin
tmpHandle := Application.Handle;
Application.Handle := MyHandle;
TmpForm:=TCustomerOrderList.Create(Application);
try
TmpForm.ShowModal;
finally
TmpForm.Free;
end;
Application.Handle := tmpHandle;
end;Exports
ShowCustomerOrderList; //记得要这个
BEGIN
END.
unit DLLFrm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls;type
TFrmDLL = class(TForm)
Label1: TLabel;
Button1: TButton;
Memo1: TMemo;
MainMenu1: TMainMenu;
private
{ Private declarations }
public
{ Public declarations }
end;
procedure showDLLModalForm(aHandle : THandle);stdcall;
procedure showDLLForm(aHandle : THandle);stdcall;
var
FrmDLL: TFrmDLL;implementation
procedure showDLLModalForm(aHandle : THandle);stdcall;
begin
Application.Handle :=aHandle;
with TfrmDLL.Create(Application) do
begin
try
showmodal;
finally
free;
end;
end;
end;
{$R *.dfm}procedure showDLLForm(aHandle : THandle);stdcall;
begin
Application.Handle :=aHandle;
with TfrmDLL.Create(Application) do
show;
end;end.
library DLLShowForm;uses
SysUtils,
Classes,
DLLFrm in 'DLLFrm.pas' {FrmDLL};{$R *.res}
exports
showdllmodalform,showdllform;
begin
end.
上面是DLL文件
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure showdllmodalform(aHandle : THandle);stdcall external 'DLLShowForm.dll';
procedure showdllform(aHandle : THandle);stdcall external 'DLLShowForm.DLL';
var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
aHandle : Thandle;
begin
//aHandle := application.Handle;
showdllform(application.Handle);
end;procedure TForm1.Button2Click(Sender: TObject);
var
aHandle : Thandle;
begin
//aHandle := application.Handle;
showdllmodalform(application.Handle);
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure showdllmodalform(aHandle : THandle);
procedure showdllform(aHandle : THandle);
var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
aHandle : Thandle;
begin
//aHandle := application.Handle;
showdllform(application.Handle);
end;procedure TForm1.Button2Click(Sender: TObject);
var
aHandle : Thandle;
begin
//aHandle := application.Handle;
showdllmodalform(application.Handle);
end;end.
//不用这些再试试stdcall external 'DLLShowForm.DLL';
就是在编写DLLShowForm的时候,关联一个这个调用它的EXE文件的时候也是不行的