读书人

Delphi入门有关问题:创建带窗口的DLL

发布时间: 2012-08-11 20:50:31 作者: rapoo

Delphi入门问题:创建带窗口的DLL
刚接触Delphi开发,参照了一些书的例子创建一个带窗口的DLL。
参考的文章:http://info.52z.com/html/28686.html
文章中提到的步骤:
方法是:
1)首先按普通方法制作窗体,不过在interface区域,对接口函数做如下声明
function Createform(capt:string):string;stdcall;
2)在implementation下加入接口函数


按照第一步,在interface区域加声明

interface
function Createform(capt:string):string;stdcall;

编译提示:
[Error] Unit1.pas(6): Declaration expected but 'USES' found

这到底是怎么回事呢, 文章中的步骤1)是到底什么意思??!!!


代码如下:

Delphi(Pascal) code
unit Unit1;interface   function Createform(capt:string):string;stdcall;   uses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls;type  TForm1 = class(TForm)    btn1: TButton;    procedure btn1Click(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;var  Form1: TForm1;implementation{$R *.dfm}function Createform(capt:string):string;stdcall;varform1: TForm1;begin    form1:=TForm1.Create(application);form1.show;form1.caption:=capt;end;procedure TForm1.btn1Click(Sender: TObject);beginShowMessage('Heelo');end;end.


[解决办法]
Delphi(Pascal) code
unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs;type  TForm1 = class(TForm)  private    { Private declarations }  public    { Public declarations }  end;function Createform(capt:string):string;stdcall;var  Form1: TForm1;implementation{$R *.dfm}function Createform(capt:string):string;stdcall;var  form1: TForm1;begin  form1:=TForm1.Create(application);  form1.show;  form1.caption:=capt;end;......
[解决办法]
"...在interface区域..."是指interface至implementation之间的位置,不是紧跟的意思;你将函数定义“function Createform(capt:string):string;stdcall;”语句放在uses语句之上,它自然就出那个提示了。

读书人网 >.NET

热点推荐