国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Delphi > 正文

Delphi 根據字符串找到函數并執行的實例

2020-01-31 20:50:18
字體:
來源:轉載
供稿:網友

Delphi 根據字符串找到函數并執行的實例

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

實例代碼:

unit Unit1;  interface  uses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls;  type   TShowInfo = procedure(info:string) of object;  //聲明一個procedure類型,參數和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('中華人民共和國');         //執行  end; end;  end. 

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 滦南县| 商河县| 岳阳市| 双牌县| 晋中市| 岐山县| 温泉县| 山丹县| 宜兰市| 乐平市| 瓦房店市| 玛曲县| 武义县| 韶关市| 海门市| 南宁市| 都兰县| 平定县| 建瓯市| 涟源市| 顺昌县| 陈巴尔虎旗| 昌黎县| 会东县| 广饶县| 玉屏| 雷波县| 定陶县| 土默特左旗| 舒兰市| 通许县| 永靖县| 富阳市| 镇坪县| 商都县| 永年县| 南川市| 尚志市| 临沧市| 天镇县| 姚安县|