我是一个初学者.
想知道dll是如何做的.
而且我想知道具体的每一步操作.
如:格式如何写,写完后如何才能进行编译,也就是说,我怎么才能看见我做的dll文件.
请高手们不赐吝教,谢过.

解决方案 »

  1.   

    //转过来给你看看,以前我回答的
    //下面为DLL
    library findCtrl;
    uses
      SysUtils,
      Classes,
      Unit1 in 'Unit1.pas';{$R *.res}
      exports
        GetString,
        FindCtrol;
    begin
    end.
    //DLL的单元
    unit Unit1;
    interface
      uses
        Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
        Dialogs, StdCtrls;  function FindCtrol(handle: THandle): TWinControl; stdcall;
    implementationfunction FindCtrol(handle: THandle): TWinControl; stdcall;
    begin
      Result := FindControl(handle);
    end;
    end.//下面为调用DLL
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TFindCtrol = function (handle: THandle): TWinControl; stdcall;
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      myFindCtrol: TFindCtrol;
      Ctrol: TWinControl;
      Hwd: Cardinal;
    begin
      Hwd := LoadLibrary(Pchar('F:\Dll\findCtrl.dll'));
      try
        if Hwd <> 0 then
        begin
          myFindCtrol := GetProcAddress(Hwd, Pchar('FindCtrol'));
          if @myFindCtrol <> nil then
            Ctrol := myFindCtrol(Button1.Handle);
        end;
        if Ctrol <> nil then
          ShowMessage(Ctrol.Name);
      finally
        if Hwd <> 0 then
          FreeLibrary(Hwd);
      end;
    end;end.
    //记住每个工程里面都得调用 vcl这个运行包. 把每个工程的 build with runtime packages 勾上就可以了.