我只准备把主窗体和一些基本设置窗体做在EXE里面,其他窗体都走成一个一个的DLL。不知道怎么做?
而且,如果我有100百个其他窗体,要弄成100个DLL吗?那样太多了吧?有什么其他办法?我的窗体上用了界面控件,如果全做在EXE里面,EXE太大了。呵呵。谢谢帮忙

解决方案 »

  1.   

    基於組什式開發呀,做成com+組件吧。
      

  2.   

    把其他窗体做成一个DLL不就可以了吗?然后在主窗体中External 加上你的DLL路径和文件名不就可以了吗?当然还要看你是静态调用还是动态调用了
      

  3.   

    下面是Delphi6开发指南的代码:(你可以去网上下载代码)
    //--------DLL-----------------------------------
    { Copyright ?2001 Delphi 6 Developer's Guide Xavier Pacheco
      and Steve Teixeira }
    library CalendarLib;uses
      ShareMem,
      SysUtils,
      Classes,
      DLLFrm in 'DLLFrm.pas' {DLLForm};exports
      ShowCalendar;
      
    begin
    end.{ Copyright ?2001 Delphi 6 Developer's Guide Xavier Pacheco
      and Steve Teixeira }
    -----------------------------------------------
    unit DLLFrm;interfaceuses
      SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
      Forms, Dialogs, Grids, Calendar;type  TDLLForm = class(TForm)
        calDllCalendar: TCalendar;
        procedure calDllCalendarDblClick(Sender: TObject);
      end;{ Declare the export function }
    function ShowCalendar(AHandle: THandle; ACaption: String): TDateTime; StdCall;implementation
    {$R *.DFM}function ShowCalendar(AHandle: THandle; ACaption: String): TDateTime;
    var
      DLLForm: TDllForm;
    begin
      // Copy application handle to DLL's TApplication object
      Application.Handle := AHandle;
      DLLForm := TDLLForm.Create(Application); 
      try
        DLLForm.Caption := ACaption;
        DLLForm.ShowModal;
        Result := DLLForm.calDLLCalendar.CalendarDate; // Pass the date back in Result
      finally
        DLLForm.Free;
      end;
    end;procedure TDLLForm.calDllCalendarDblClick(Sender: TObject);
    begin
      Close;
    end;end.
    //--------调用程序--------------------
    { Copyright ?2001 Delphi 6 Developer's Guide Xavier Pacheco
      and Steve Teixeira }
    unit MainFfm;interfaceuses
      SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
      Forms, Dialogs, StdCtrls;type
      { First, define a procedural data type, this should reflect the
        procedure that is exported from the DLL. }
      TShowCalendar = function (AHandle: THandle; ACaption: String): TDateTime; StdCall;  { Create a new exception class to reflect a failed DLL load }
      EDLLLoadError = class(Exception);  TMainForm = class(TForm)
        lblDate: TLabel;
        btnGetCalendar: TButton;
        procedure btnGetCalendarClick(Sender: TObject);
      end;var
      MainForm: TMainForm;implementation{$R *.DFM}procedure TMainForm.btnGetCalendarClick(Sender: TObject);
    var
      LibHandle   : THandle;
      ShowCalendar: TShowCalendar;
    begin  { Attempt to load the DLL }
      LibHandle := LoadLibrary('CALENDARLIB.DLL');
      try
        { If the load failed, LibHandle will be zero.
          If this occurs, raise an exception. }
        if LibHandle = 0 then
          raise EDLLLoadError.Create('Unable to Load DLL');
        { If the code makes it here, the DLL loaded successfully, now obtain
          the link to the DLL's exported function so that it can be called. }
        @ShowCalendar := GetProcAddress(LibHandle, 'ShowCalendar');
        { If the function is imported successfully, then set lblDate.Caption to reflect
          the returned date from the function. Otherwise, show the return raise
          an exception. }
        if not (@ShowCalendar = nil) then
          lblDate.Caption := DateToStr(ShowCalendar(Application.Handle, Caption))
        else
          RaiseLastWin32Error;                                                               
      finally
        FreeLibrary(LibHandle); // Unload the DLL.
      end;
    end;end.
      

  4.   

    有两个方法.一个是使用BPL,一个是用DLL
    BPL象平时引用一样。不过因为是动态的,发布时你要把delphi的和你用的控件的那些BPL也带上
    用DLL时,使用标准的导出接口就行。用DLL和一般的编程没什么不同。只是要在实现里再创建窗体等实例。如果不想处理消息,最简单的就是用模态窗口,关闭后free就行。