这样:
FUNC(P1:INTEGER。VAR PN:PCHAR):BOOLEAN;STDCALL;

解决方案 »

  1.   

    dll文件
    library Project3;{ Important note about DLL memory management: ShareMem must be the
      first unit in your library's USES clause AND your project's (select
      Project-View Source) USES clause if your DLL exports any procedures or
      functions that pass strings as parameters or function results. This
      applies to all strings passed to and from your DLL--even those that
      are nested in records and classes. ShareMem is the interface unit to
      the BORLNDMM.DLL shared memory manager, which must be deployed along
      with your DLL. To avoid using BORLNDMM.DLL, pass string information
      using PChar or ShortString parameters. }uses
      SysUtils,
      Classes,
      Unit2 in 'Unit2.pas' {Form1};{$R *.res}
    exports
      showform,
      closeform;
    //  DoTest;
    beginend.
    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, DB, ADODB;type
      TForm2 = class(TForm)
        ADOConnection1: TADOConnection;
        Memo1: TMemo;
      private
        { Private declarations }
      public
        { Public declarations }
      end;procedure DoTest(H: THandle; { 获得调用者的句柄       }
      AConn: TADOConnection; { 获得调用者的数据库连接 }
      S: string; { 获得一些文本信息       }
      N: Integer); { 获得一些数值信息       }
    cdecl; { 指定调用协议           }
    function showform(Ahandle: Thandle; Acaption: string): longint; stdcall;procedure closeform(Aformref: longint); stdcall;implementation{$R *.DFM}procedure DoTest(H: THandle; AConn: TADOConnection; S: string; N: Integer);
    begin
      Application.Handle := H; { 将过程的句柄赋值为调用者的句柄 }
      { 上面语句的作用在于, DLL的句柄和调用者的句柄相同,在任务栏中就不会   }
      { 各自出现一个任务标题了。                                             }
      with TForm2.Create(Application) do
      try { 创建窗体                       }
        Memo1.Lines.Append('成功调用'); { 显示一行信息                   }
        ADOConnection1 := AConn; { 获得数据库连接的实例           }
        Memo1.Lines.Append(
          ADOConnection1.ConnectionString +
          ' - ' + S + ' - ' + IntToStr(N)); { 根据得到的参数显示另一行信息   }
       ShowModal;                          { 模式化显示窗体                 }
      finally
        Free; { 调用结束时销毁窗口             }
      end;
    end;function showform(AHandle: THandle; Acaption: string): longint;
    var
      form2: Tform2;
    begin
      showmessage('0');
      Application.Handle := AHandle;
      showmessage('1');
      form2 := Tform2.Create(application);
      showmessage('2');
      result := longint(form2);
      showmessage('3');
      form2.Caption := Acaption;
      form2.Show;end;procedure closeform(Aformref: longint);
    begin
      if Aformref > 0 then
        Tform2(Aformref).Free;
    end;
    end.
      

  2.   

    调用
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, DB, ADODB, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        ADOConnection1: TADOConnection;
        Button2: TButton;
        Button3: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure DoTest(H: THandle; { 传递句柄       }
      AConn: TADOConnection; { 传递数据库连接 }
      S: string; { 传递文本信息   }
      N: Integer); { 传递数值信息   }
    cdecl; { 指定调用协议   }
    external 'Project2.dll'; { 指定过程来源   }{ 调用过程 }procedure TForm1.Button1Click(Sender: TObject);
    begin
      DoTest(Application.Handle,
        ADOConnection1,
        'Call OK',
        256);
    end;end.