从盒子上下的源码,作者说是delphi5编的,但是我用delphi7缺无法编译,不知道是什么问题,代码很简单,就是bpl中的exports不能导出字符串变量。我看了delphi7的帮助,说只能导出过程名或者函数名,但是为什么delphi5就可以编译呢?
代码如下:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
g_HelloStr: string = 'Hello, I am Michael!';
procedure SayHello(msg: string);exports
SayHello,
g_HelloStr;implementation{$R *.DFM}procedure SayHello(msg: string);
begin
ShowMessage(msg);
end;{ The following call Registers the addin with the application. Once
this occurs the application can create instances of this form. }
initialization
RegisterClass(TForm1);end.错误提示:
[Error] Unit1.pas(26): Identifier 'g_HelloStr' cannot be exported
代码如下:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
g_HelloStr: string = 'Hello, I am Michael!';
procedure SayHello(msg: string);exports
SayHello,
g_HelloStr;implementation{$R *.DFM}procedure SayHello(msg: string);
begin
ShowMessage(msg);
end;{ The following call Registers the addin with the application. Once
this occurs the application can create instances of this form. }
initialization
RegisterClass(TForm1);end.错误提示:
[Error] Unit1.pas(26): Identifier 'g_HelloStr' cannot be exported
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
g_HelloStr: string;
procedure SayHello(msg: string);exports
SayHello,
g_HelloStr;implementation{$R *.DFM}procedure SayHello(msg: string);
begin
ShowMessage(msg);
end;{ The following call Registers the addin with the application. Once
this occurs the application can create instances of this form. }
initialization
g_HelloStr := 'Hello, I am Michael!';
RegisterClass(TForm1);end.实在不行这么改吧,应该是编译器限制了。