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;
相关文档:
absolute
//它使得你能够创建一个新变量, 并且该变量的起始地址与另一个变量相同.
var
Str: string[32];
StrLen: Byte absolute Str;
//这个声明指定了变量StrLen起始地址与Str相同.
//由于字符串的第0个位置保存了字符串的长度, 所以StrLen的值即字符串长度.
begin
Str := 'abc';
Ed ......
曹祖权
工具条是程序员喜欢采用的组件,它具有简明直观的外形,能够方便用户执行最常用的功能。如果你使用delphi3编程,那么本人向你推荐coolbar组件。它是一种功能更为丰富的工具条,用它可以使多个传统的工具条、编辑框、组合列表框、图像甚至更多的组件集成到一个统一的coolbar中,使得应用程序窗口更为紧凑、界面 ......
Delphi 2010只剩下六天的试用期了,15天的试用期过得真快.百度了很久也依旧未搜索到破解补丁,看来这版本的防盗版工作做得确实不错.无奈之下只好自己对它做做手脚了.
测试了一下,delphi只有在启动程序的时候把时间记录给更新到当前日期,系统内并不驻留相应的 ......
在编译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
  ......