下面是我写的一个简单的demo,想请大家告诉我怎么把它转换成一个dll文件!unit demo;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,IniFiles, Mask;type
  TForm1 = class(TForm)
    Button1: TButton;
    Button4: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button5: TButton;
    ComboBox1: TComboBox;
    ScrollBar1: TScrollBar;
    Button3: TButton;
    Button6: TButton;
    Button7: TButton;
    Button2: TButton;
    Button8: TButton;
    RadioButton1: TRadioButton;
    ListBox1: TListBox;
    MaskEdit1: TMaskEdit;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  IniFile,IniFile1: TIniFile;
  total,wCount: Integer;
  slabel,nName,nLanguage,nShortcuts,nColor,nSize,nTips,nRes: string;implementation{$R *.dfm}function SplitStr(var AStr: string; ASplitChar: Char = ';'): string; //截取字串
var
  sF: string;
begin
  sF := '';
  if AStr <> '' then
    if Pos(ASplitChar, AStr) > 0 then
    begin
      sF := Copy(AStr, 1, Pos(ASplitChar, AStr) - 1);
      AStr := Copy(AStr, Pos(ASplitChar, AStr) + 1, MaxInt);
    end
    else
    begin
      sF := AStr;
      AStr := '';
    end;
  Result := sF;
end;procedure TForm1.FormCreate(Sender: TObject);
var
i,wCount:integer;
IniFile: TIniFile;
begin
  {生成語言庫}
  IniFile:=TInifile.Create(ExtractFilePath(ParamStr(0))+'demo1.ini');
  IniFile.WriteInteger('language','ivar',0);
  IniFile.WriteInteger('frmCount','wCount',1);
  wCount:=IniFile.ReadInteger('frmCount','wCount',1);
  IniFile.WriteInteger('frm'+IntToStr(wCount),'total',Componentcount);
  IniFile.WriteString('frm'+IntToStr(wCount),'frmCaption','form'+IntToStr(wCount));
  form1.Caption:=IniFile.ReadString('frm'+IntToStr(1),'frmCaption','');
  for i := 1 to Componentcount do
  begin
    iniFile.WriteString('frm'+IntToStr(wCount),'label'+IntToStr(i),TForm(Components[i-1]).Caption+'^'+TForm(Components[i-1]).ClassName+'^'+''+'^'+inttostr(TForm(Components[i-1]).Font.Color)+'^'+inttostr(TForm(Components[i-1]).Font.Size)+'^'+TForm(Components[i-1]).Hint+'^'+'');
  end;
  copyfile('demo1.ini' ,'language.ini',false);
  deletefile(ExtractFilePath(ParamStr(0))+'demo1.ini');
  {調用語言庫}
  for i := 1 to Componentcount do
  begin
    IniFile1:=TInifile.Create(ExtractFilePath(ParamStr(0))+'lang\language.ini');
    slabel:=IniFile1.ReadString('frm'+IntToStr(1),'label'+IntToStr(i),'');
    nName:=SplitStr(slabel,'^');
    nLanguage:=SplitStr(slabel,'^');
    nShortcuts:=SplitStr(slabel,'^');
    nColor:=SplitStr(slabel,'^');
    nSize:=SplitStr(slabel,'^');
    nTips:=SplitStr(slabel,'^');
    nRes:=SplitStr(slabel,'^');
    if nName<>'' then
    begin
      TForm(Components[i-1]).Caption:=nName;
      TForm(Components[i-1]).Font.Color:=strtoint(nColor);
      TForm(Components[i-1]).Font.Size:=strtoint(nSize);
      TForm(Components[i-1]).Hint:=nTips;
    end;
  end;
end;end.

解决方案 »

  1.   

    File->New->Other->Dll   Wizard新建一个以Library开头的工程文件
      library   HkTest;   
        
      uses   
          UCoord   in   UCoord.pas';//把你的UCoord.pas加入工程   
        
      exports//输出部分   
          EnableHotKeyHook,//供外面调用的函数   
          
      begin   
        
      end.   
    然后就是你的pas文件了,和其他的pas编写是一样的
      

  2.   

    你建一个dll工程,把过程改乘汉书就可以拉,和你正常的application里面一样啊,只是调用的时候有点不太一样。
      

  3.   

    library Project1;{ 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,
      IniFiles,Forms,
      Windows;{$R *.res}procedure Getinifile(Componentcount:Integer;Components:array of TComponent);   stdcall;
    var
    i:integer;
    IniFile: TIniFile;
    begin
      {生成語言庫}
      IniFile:=TInifile.Create(ExtractFilePath(ParamStr(0))+'demo1.ini');
      IniFile.WriteInteger('language','ivar',0);
      IniFile.WriteInteger('frmCount','wCount',1);
      IniFile.WriteInteger('frm'+IntToStr(1),'total',Componentcount);
      IniFile.WriteString('frm'+IntToStr(1),'frmCaption','form'+IntToStr(1));
      for i := 1 to Componentcount do
      begin
        iniFile.WriteString('frm'+IntToStr(1),'label'+IntToStr(Components[i-1]),TForm(Components[i-1]).Caption+'^'+TForm(Components[i-1]).ClassName+'^'+''+'^'+inttostr(TForm(Components[i-1]).Font.Color)+'^'+inttostr(TForm(Components[i-1]).Font.Size)+'^'+TForm(Components[i-1]).Hint+'^'+'');
      end;
      copyfile('demo1.ini' ,'language.ini',false);
    end;exports
     Getinifile;begin
    end.都等于没有说!有好多东西要改变的,知道的话我还用问吗?
    例如IntToStr(Components[i-1])这句在程序中没有错,现在就没有办法用了!因为Components[i-1]的属性现在就不是integer啦!
      

  4.   

    不是搞错了!是在调用时Components[i-1]出错!
    procedure Getinifile(Componentcount:Integer;Components:array of TComponent);
    stdcall;external 'Project1.dll';procedure TForm1.FormCreate(Sender: TObject);
    var
    i:Integer;
    begin
      Getinifile(Componentcount,Components[i-1]);
    end;
      

  5.   

    上面的代码写错了!这是完整的unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    procedure Getinifile(Componentcount:Integer;Components:array of TComponent);
    stdcall;external 'Project1.dll';procedure TForm1.FormCreate(Sender: TObject);
    var
    i:Integer;
    begin
     for I := 0 to Componentcount do
       
      Getinifile(Componentcount,Components[i-1]);
    end;end.
      

  6.   

      Delphi5 开发人员指南第9章详解.足有30多页讲解,够全了.  www.2ccc.com下载.