不用VCL,那样dll好几百K.

解决方案 »

  1.   

    在project单元的内容:
    library Project1;uses
      Forms,
      Unit1 in 'Unit1.pas' {Form1};procedure test;
    begin
      Application.CreateForm(TForm1, Form1);
      form1.show;
    end;
    {$R *.res}
    exports test;
    begin
    end.在unit单元的内容:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}end.这样编译后就是一个dll了。
      

  2.   

    调用dll的时候,在project的内容:
    program Project1;uses
      Forms,
      Unit2 in 'Unit2.pas' {Form1};{$R *.res}begin
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end.在unit单元的内容:
    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;procedure test; far;external 'project2.dll';implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      test;
    end;end.
    如果这个看不懂,我就没办法了
      

  3.   

    to tomp()
    你这个DLL怕有200K吧?再加点控件就过300了我只是想知道怎么用SDK加上窗口,在窗口放一些控件,DLL和普通Exe不一样,有些工作要做,我想有经验的给点Tip, 我可以少走弯路.
      

  4.   

    单片机开发吗?怎么对DLL大小要求这么严.
      

  5.   

    project-option-package-build with packages..然后发布的时候把bpl和所有dll放到同一目录下
      

  6.   

    只包含一个form的话,dll带包编译只有11k左右,如果是10个dll加上bpl也只有几百k,dll和bpl文件都可以加壳压缩
      

  7.   

    单片机开发吗?怎么对DLL大小要求这么严.
    我不想他太大而已,做成DLL就是为了小.
    带包编译啊
    这样还是大(加上包),不过DLL多了就不觉得了,但其他语言能调用吗?
      

  8.   

    和EXE一样,只要接口函数中有SHOW就可以了
      

  9.   

    要小,可以在编译设置中做到,DLL也只有几十K
      

  10.   

    我来抛块砖吧:)
    DLL:
    unit U_APIform;interfaceuses
      Windows, Messages, SysUtils;function ShowAPIModlessForm(AHandle: THandle): Longint; stdcall;implementationconst
      AppName = 'DllAPIform';function DummyWindowProc (Wnd: hWnd; Msg, wParam: Word;
      lParam: LongInt): LongInt; stdcall;
    begin
      Result := 0;
      case Msg of
        WM_DESTROY: PostQuitMessage(0);
      else
        Result := DefWindowProc(Wnd, Msg, wParam, lParam);
      end;
    end;function ShowAPIModlessForm(AHandle: THandle): Longint;
    var
      cls: TWndClass;
      Wnd: hWnd;
    begin
      Result := 0;
      FillChar(cls, SizeOf(cls), 0);
      cls.lpfnWndProc := @DummyWindowProc;
      cls.hInstance := AHandle;
      cls.lpszClassName := AppName;
      RegisterClass(cls);  Wnd := CreateWindowEx(0, AppName, AppName,
           WS_VISIBLE or //µ÷ÊÔʱÓÃ;
           WS_SIZEBOX or WS_CAPTION or WS_POPUP,
           363, 278, 305, 200, 0, 0, AHandle, nil);
      if Wnd > 0 then
      begin
        UpdateWindow(Wnd);
        ShowWindow(Wnd, SW_SHOW);
        Result := Wnd;
      end;
    end;end.library DllAPIform;uses
      U_APIform in 'U_APIform.pas';{$R *.res}exports
      ShowAPIModlessForm;begin
    end.调用:
    function ShowAPIModlessForm(AHandle: THandle): Longint;
      stdcall; external 'DllAPIform.dll';procedure TForm1.btnShowAPIModlessFormClick(Sender: TObject);
    begin
      if FAPIForm = 0 then
        FAPIForm := ShowAPIModlessForm(Application.Handle);
    end;这样就可以把DLL中的无模式子窗体显示出来了:)