运行DLL时,总是出现这句'Cannot debug project unless a host application is defined use the run|paramters..dialog box.'这是怎么回事呢??

解决方案 »

  1.   

    运行Dll时没有设置调用主程序的参数。
    RUN->Parameters->在Host Application 中输入你要调用的主程序EXE 文件
      

  2.   

    在编译dll文件时你应该 Project->Build Project1 来编译
    如果要调试 应该先 run->paramters 来关联一可执行文件,之后在点Run 就可以了
      

  3.   

    我关联了一个EXE文件后,再RUN的时候,会出现内存地址出错啊!
      

  4.   

    Project->Build Project1 是生成了一个DLL的文件,但是我在别的工程调用的出现,'无法找到入口'的错误提示????
      

  5.   

    可能是你的DLL文件出错了。重新检查下代码吧。
      

  6.   

    代码没问题的啊,Project->Build Project1 可以生成了一个DLL的文件
      

  7.   

    procedure LoadDllFile(const dllPath,functinName: string);
    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;这是我自己的代码,参考下。
      

  8.   

    procedure ShowCustomerOrderList(MyHandle: THandle);
    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.
      

  9.   

    我把我的代码,贴出来:
    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文件
      

  10.   

    下面是调用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.
      

  11.   

    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);
    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';
      

  12.   

    你是说用动态调用试试吗?
    就是在编写DLLShowForm的时候,关联一个这个调用它的EXE文件的时候也是不行的