欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Delphi 根據(jù)字符串找到函數(shù)并執(zhí)行的實例

 更新時間:2017年09月03日 16:21:42   投稿:lqh  
這篇文章主要介紹了Delphi 根據(jù)字符串找到函數(shù)并執(zhí)行的實例的相關(guān)資料,希望通過本能幫助到大家實現(xiàn)這樣的功能,需要的朋友可以參考下

Delphi 根據(jù)字符串找到函數(shù)并執(zhí)行的實例

 關(guān)鍵字:MethodAddress:取得方法的地址,這個方法需要是published的。

實例代碼:

unit Unit1; 
 
interface 
 
uses 
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
 Dialogs, StdCtrls; 
 
type 
 
 TShowInfo = procedure(info:string) of object;  //聲明一個procedure類型,參數(shù)和ShowInfo一致 
 
 TForm1 = class(TForm) 
  Button1: TButton; 
  procedure Button1Click(Sender: TObject); 
 private 
  { Private declarations } 
 public 
  { Public declarations } 
 
 published 
  procedure ShowInfo(info:string); 
 end; 
 
var 
 Form1: TForm1; 
 
implementation 
 
{$R *.dfm} 
 
{ TForm1 } 
 
procedure TForm1.ShowInfo(info: string); 
begin 
 ShowMessage(info); 
end; 
 
procedure TForm1.Button1Click(Sender: TObject); 
var 
 s:TShowInfo; 
begin 
 @s := MethodAddress('ShowInfo');    //取得ShowInfo的地址 
 if @s <> nil then           //如果不為空 
 begin 
  s('中華人民共和國');         //執(zhí)行 
 end; 
end; 
 
end. 

如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論