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中实现全角转半角
function SbctoDbc(s:string):string;
var
nlength,i:integer;
str,ctmp,c1,c2:string;
{
在windows中,中文和全角字符都占两个字节,
并且使用了ascii chart 2
(codes 128 - 255
)。
全角字符的第一个字节总是 ......
Delphi 2010只剩下六天的试用期了,15天的试用期过得真快.百度了很久也依旧未搜索到破解补丁,看来这版本的防盗版工作做得确实不错.无奈之下只好自己对它做做手脚了.
测试了一下,delphi只有在启动程序的时候把时间记录给更新到当前日期,系统内并不驻留相应的 ......
Delphi动态事件深入分析
2009-2-7
作者:不得闲
核心提示:本实验证明了在类中方法的调用时候,所有的方法都隐含了一个Self参数,并且该参数作为对象方法的第一个参数传递...
首先做一个空窗体,放入一Button。
在implementation下面声明两个方法如下:
//外部方法,只声明一个参数,此时按照标准的对象内部事件方法T ......
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.
反汇编出来会是 ......