小弟今天看书,关于窗口重调用的问题,自己也动手也编了一个简单的例子,来练练手,但是老是编译不过去,不知道是什么原因,请求大家的帮助,项目文件如下;
  library project1;uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};exports
    addstr;{$R *.res}begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
就下来就是unit1了,如下:unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure addstr; 
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation
 
{$R *.dfm}procedure Tform1.addstr;
  var s:string;
 begin
      s:=inputbox('put','please input','');
     memo1.Lines.Append(s);   end;procedure TForm1.Button1Click(Sender: TObject);
begin
addstr;
end;end.
编译的时候,项目文件提示,不知道addstr是什么,希望大家帮我看看,告诉我,谢谢了。

解决方案 »

  1.   

    你的是dll,这个
    begin
      //Application.Initialize;  统统去掉
      //Application.CreateForm(TForm1, Form1);
      //Application.Run;
    end.interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls;type
      TForm1 = class(TForm)
        Memo1: TMemo;
        Button1: TButton;
        //procedure addstr;   改成全局过程 
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
     
    {$R *.dfm}procedure addstr;  stdcall;
    var s:string;
      Form1: TForm1; 
    begin
       try
         Form1 := TForm1.Create(Application);
         Form1.ShowModal;
          s:=inputbox('put','please input','');
         Form.memo1.Lines.Append(s);
      finally
        FreeAndNil(Form1);
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    addstr;
    end;end.
    编译的时候,项目文件提示,不知道addstr是什么,希望大家帮我看看,告诉我,谢谢了。
      

  2.   

    你原来除了把program改成了libraby什么也没动啊,但是dll的所有对象都要动态创建的
    和exe是不同的
      

  3.   

    不知道为什么,找楼上的改了后,还是exports addstr;这里出问题,提示是不匹配,ljmanage(过客)再来救救我,
      

  4.   

    把“ procedure addstr;  stdcall;”声明放在 implementation 前面,即在implementaiton前加一行“procedure addstr;  stdcall;”,否则library找不到它。