Z
zw84611
Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何使用函数指针,如我想实现以下功能:
type
TForm1 = class(TForm)
......
public
{ Public declarations }
function CheckMP3(s:string):boolean;
end;
function TForm1.CheckMP3(s:String):boolean;
begin
if pos('.mp3',lowercase(s))<>0 then Result:=true else Result:=false;
end;
procedure TForm1.BtnClick(Sender: TObject);
var CheckFunc: function(s:string):boolean;
begin
@CheckFunc:=MethodAddress('CheckMP3')
if CheckFunc('1.mp3') ShowMessage('ok');
end;
但这样不行,请问该怎么做?
type
TForm1 = class(TForm)
......
public
{ Public declarations }
function CheckMP3(s:string):boolean;
end;
function TForm1.CheckMP3(s:String):boolean;
begin
if pos('.mp3',lowercase(s))<>0 then Result:=true else Result:=false;
end;
procedure TForm1.BtnClick(Sender: TObject);
var CheckFunc: function(s:string):boolean;
begin
@CheckFunc:=MethodAddress('CheckMP3')
if CheckFunc('1.mp3') ShowMessage('ok');
end;
但这样不行,请问该怎么做?