Delphi中使用@取函数地址的问题
例如以下代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs;
type
TForm1 = class(TForm)
procedure one();
function two(x,y:integer):integer;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.one();
var
p : pointer;
begin
p:=@two;
end;
function TForm1.two(x,y:integer):integer;
begin
Result:=x+y;
end;
end.
在Delphi5中,没有任何问题,到了delphi7、2007、2009中就会报错:需要变量(Delphi6没试)
原因是新版本中要求返回函数地址的函数必须是全局函数,所以程序要改成这样:
................................
var
Form1: TForm1;
function two(x,y:integer):integer;
................................
function two(x,y:integer):integer;
相关文档:
32位Delphi程序中可利用TRegistry对象来存取注册表文件中的信息。
一、创建和释放TRegistry对象
1.创建TRegistry对象。为了操作注册表,要创建一个TRegistry对象:ARegistry := TRegistry.Create;
&n ......
有些时候,要写一些程序,在 JAVA 里面好难实现, 但如果使用其它编程语言却又比较容易时,我们不妨通过 JNI 来让不同语言的程序共同完成.
JNI 的教程, 网上 C 的比较多,Java 也提供了 javah.exe 为 C 语言的 JNI 程序生成头文件, 如果你是一个 Delphi 编程员, 能否让 JAVA 与 Delphi 程序交互呢? 答案是肯定的,今天我们就来 ......
技术交流,DH讲解. 这个是在CSDN上面看见的问题.我说说自己的想法. procedure TForm1.btn1Click(Sender: TObject);
var
Str:String;
begin
Str:='abc' ;
Str:=str+'d';
str:=copy(Str,1,3);
str:=UpperCase(str);
end;
问题1答案:2010下
Unit4.pas.29: begin
005144E0 55 p ......
在编译delphi程序时会出现在些提示,全是E文的,现在给大家一个对照表,可以更好的理解错误提示信息!
';' not allowed before 'ELSE' ElSE前不允许有“;”
'' clause not allowed in OLE automation section 在OLE自动区段不允许“”子句
'' is not a type identifier 不是类型标识符
'' not prev ......
方法1:可写为函数,再调用
Application.CreateForm(TForm1, Form1);
Form1.ShowModal;
Form1.Free;
方法2:
Form1:= TForm1.Create(Application);
try
Form1.ShowModal;
finally
  ......