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; ......

 

Delphi中使用@取函数地址的问题(转)的更多相关文章

  1. Delphi中的四舍五入函数

    一.Delphi中的四舍五入法     四舍五入是一种应用非常广泛的近似计算方法,针对不同的应用需求,其有算术舍入法和银行家舍入法两种.     所谓算术舍入法,就是我们通常意义上的四舍五入法.其规则 ...

  2. delphi中Application.MessageBox函数用法详解

    delphi中Application.MessageBox函数用法详解 Application.MessageBox是TApplication的成员函数,声明如下:functionTApplicati ...

  3. Delphi中的Val函数和iif函数(出错的时候,会有索引值)

    在delphi中Val是一个将字符串转换为数字的函数,Val(S; var V; var Code: Integer)第一个参数是要转换的字符串,第二个参数存放转换后的数字,可以是整数或浮点数,第三个 ...

  4. DELPHI 中的Delay函数,利用GetTickCount和Application.ProcessMessages构建

      作者 关劲松           delphi 开发中有些时候需要停留片刻,等待界面输入,或异步操作完成,如果使用sleep函数的话,整个程序都会停顿,界面还会出现冻结的情况.因此需要自行编写一个 ...

  5. FastReport调用Delphi中的自定义函数(人民币大写金额)mtm

    1. 在 FormCreate 中向FastReprot添加函数 (fPrint)窗口 procedure TfPrint.FormCreate(Sender: TObject); frxReport ...

  6. Delphi中的Rtti函数

    TTypeKind,类型类别,tkclass,tkinteger,tkstring等.类,属性都是一种类型. ttypedata,是一个record包括ttypekind.是一个类的描述.TTypeK ...

  7. delphi中的copy函数和pos函数

    1.copy(‘csdn’,1,2) 返回的结果是 cs 注释: Copy有3个参数,第一个是要处理的字符串,第二个是要截取的开始位置,第三个是截取位数 当第三个参数大于字符长度,那么效果就是取开始位 ...

  8. 在Delphi中实现HexToStr函数和StrToHex函数

    function TransChar(AChar: Char): Integer; begin '] then Result := Ord(AChar) - Ord(') else Result := ...

  9. Delphi 中的 IfThen 函数

    问题来源: http://www.cnblogs.com/del/archive/2008/11/14/1120015.html#1370413 StrUtils 单元和 Math 单元 分别有一个 ...

随机推荐

  1. android 打开软件出现红框

    android打开软件的时候会出现红框,剑锋之前解了这个问题.fork过来,方便以后查看. 参考链接: http://www.cnblogs.com/zengjfgit/p/5377744.html ...

  2. eclipse for hello world makefile

    1. 工程文件分析 使用eclipse新建一个Hello World工程,假设工程名称是hello,此时eclipse在工程目录下新建了一个名为hello的文件夹: hello/ .cproject ...

  3. .NET基础加强,找工作之前可以看看这些............

    .NET基础知识加强: 1  变量命名规则:骆驼命名法:第一个字母小写之后的首字母大写,[对于方法名和类名首字母大写]→培养良好的命名规范. 2  构造函数:没有返回值,方法名和类名相同,每个类中都有 ...

  4. 还原ORACLE DUMP 的值

    还原DUMP出来的数字SQL> select dump(2000,16) from dual; DUMP(2000,16)------------------Typ=2 Len=2: c2,15 ...

  5. Android ListView与ExpandableListView设置分割线divider

    listview设置分割线需要以下操作: lv.setDivider(getResources().getDrawable(R.drawable.diyline)); ExpandableListVi ...

  6. celery 学习笔记 01-介绍

    celery 学习笔记 01-介绍 celery 是 python 中的常用的任务队列框架,经常用于异步调用.后台任务等工作.celery 本身以 python 写,但协议可在不同的语言中实现,其它语 ...

  7. storm安装

    官方安装地址:http://storm.apache.org/releases/1.0.2/Setting-up-a-Storm-cluster.html storm集群的三个角色 Nimbus.Su ...

  8. 在HTML中调用iOS

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. windows下使用pthreads

    pthread-win32在Windows上实现了线程相关的Posix标准,接口一模一样 包含: thread mutex cond swlock spin sem barrier https://s ...

  10. jQuery uploadify上传文件404,500错误

    1.如果部署到了IIS7的话,IIS7默认的大小为3000000.修改方法如下: 找到网站双击“请求筛选”——右边找到“编辑功能设置”——将“允许的最大内容长度”改成你想要的就行了. 2.当上传大文件 ...