前面写了个动态链接库里面有个窗体可以共享(资料上的),现在我想在主程序中把他提出来用,下面是实现其弹出对话框的函数。但我没有看明白返回值怎么是Tdatetime还有他只是函数没有执行啦怎样才能执行其代码?就是说怎样才能调出动态链库里的窗体,用比较简单的方法.下面这个好像是自已建个函数把他引出来。(1)、声明要引出的函数:
     Function showcanlendar(AHandle:THandle;Acaption:string):Tdatetime;stdcall;
(2)、函数体:
     Function showcanlendar(AHandle:THandle;Acaption:string):Tdatetime;
     var
      DLLForm:TDllForm;
     begin
      application.handle:=ahandle; DllForm:=TDllForm.create(application);
     try
      DllForm.caption:=acaption
      dllform.showmodal;
      resout:=dllform.caldllcalendar.calendardate;
     finally
      DllForm.Free; 
     end;
     end;

解决方案 »

  1.   

    (2)、函数体:
         Function showcanlendar(AHandle:THandle;Acaption:string):Tdatetime;stdcall;
      

  2.   

    楼主自己的这个例子不能用吗?
    ----------dll dpr----------
    library Project2;uses
      SysUtils,
      Forms,
      Classes,
      Unit2 in 'Unit2.pas' {DllForm};{$R *.res}Function showcanlendar(AHandle:THandle; Acaption:string):Tdatetime; stdcall;
         var
          DLLForm:TDllForm;
    begin
          application.handle:=ahandle;
          DllForm:=TDllForm.create(application);
         try
          DllForm.caption:=acaption;
          dllform.showmodal;
          result:=dllform.MonthCalendar1.Date;
         finally
          DllForm.Free; 
         end;
         end;exports
      showcanlendar;
    begin
    end.
    ---------dll form-----------
    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ComCtrls;type
      TDllForm = class(TForm)
        MonthCalendar1: TMonthCalendar;
        procedure FormShow(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      DllForm: TDllForm;implementation{$R *.dfm}procedure TDllForm.FormShow(Sender: TObject);
    begin
      Self.MonthCalendar1.Date := Now-1;
    end;end.
    --------test form--------------
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Label1: TLabel;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;  Function showcanlendar(AHandle:THandle; Acaption:string):Tdatetime; stdcall; external 'Project2.dll';var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
    Label1.Caption := FormatDateTime('YYYY-MM-DD HH:NN:SS', showcanlendar(Application.Handle, '12345'));
    end;end.
      

  3.   

    你这个是动态库中的代码
    主程序
    声明:
    Function showcanlendar(AHandle:THandle;Acaption:string):Tdatetime;stdcall;external 'you r.dll';
    调用
    showmessage(formatdatetime('yyyymmdd',showcanlendar(handle,'demo')));
      

  4.   

    感谢各位了。但是没有 exports showcanlendar; 输出这个窗体只是包含在一个大的DLL中没有
    直接的输出我想是不是只能自已建个相同的函数把DLL中的窗体函数引出来?