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;
相关文档:
曹祖权
工具条是程序员喜欢采用的组件,它具有简明直观的外形,能够方便用户执行最常用的功能。如果你使用delphi3编程,那么本人向你推荐coolbar组件。它是一种功能更为丰富的工具条,用它可以使多个传统的工具条、编辑框、组合列表框、图像甚至更多的组件集成到一个统一的coolbar中,使得应用程序窗口更为紧凑、界面 ......
15本Delphi书籍(PDF格式)下载 (转)
文件名: Delphi组件参考大全.rar
下载地址: http://www.rayfile.com/files/678ca1e3-f73f-11de-9d02-0014221b798a/
文件名: Delphi信息系统开发实例精选.rar
下载地址: http://www.rayfile.com/files/fb328f02-f73e-11de-8a76-0014221b798a/
文件名 ......
技术交流,DH讲解. 之前照着天书夜读,用Delphi来弄了下循环体,现在就来弄一下条件判断吧.
首先肯定是我们经常看见的IF语句咯. Var
I: Integer;
Begin
I:= 99;
If (I> 0)And (I< 0) Then
Writeln('I>0')
Else
If (I> 10)And (I< 100) Then
Writeln('I>10 and I100');
End.
反汇编出来会是 ......
在编译delphi程序时会出现在些提示,全是E文的,现在给大家一个对照表,可以更好的理解错误提示信息!
';' not allowed before 'ELSE' ElSE前不允许有“;”
'' clause not allowed in OLE automation section 在OLE自动区段不允许“”子句
'' is not a type identifier 不是类型标识符
'' not prev ......