我直接定义一个单元文件
interface
...
type
  TMyObject = class
  private
    { Private declarations }
  public
    constructor Create(const FileName: string); overload;
    destructor Destroy; override;
    { Public declarations }
  end;
end ;var
    ...
implementation{$R *.dfm}constructor TMyObject.Create(const FileName: string);
begin
  inherited Create;
  ...
end;destructor TMyObject.Destroy;
begin
 ...
end;然后在另一应用程序中引用该怎么做啊,我好象没作对.

解决方案 »

  1.   

    按Shift+F11把这个单元加进去,再uses 单元名。
      

  2.   

    抱歉,是我没说清楚,我是这样引用的,我新建一个应用程序,在菜单project|Add to Project,
    然后选引用单元后,在应用程序单元中引用报错(There is no overloaded version of 
    'create'that can be called with these arguments ),代码是:
    unit Unit1;
    interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs,那个单元文件名, StdCtrls;
    type
      TForm1 = class(TForm)
        procedure FormDestroy(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        myobject: TMyObject;//继承为引用单元的类
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
    implementation
    {$R *.dfm}
    procedure TForm1.FormDestroy(Sender: TObject);
    begin

      myobject.Destroy;//使用引用单元的方法
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin

    myobject.Create(某文件名);
     end;
    end.