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

首頁 > 學院 > 開發設計 > 正文

調用DLL文件中的FORM

2019-11-18 18:20:11
字體:
來源:轉載
供稿:網友
 

作者:e夢緣

好久發表文章了!!!

調用DLL文件中的FORM,具體實現過程如下:

library PRoject1;uses  SysUtils,   Classes,Forms,windows,dialogs,  Unit1 in 'Unit1.pas' {Form1};{$R *.res}function showform(formname:string):boolean;stdcall;var  TheClass: TPersistentClass;  aForm: TForm;begin result:=false; {如果您的Dll中有很多FORM,請在這兒注冊哦 RegisterClasses([TForm1,TForm2,TForm3,...]); } RegisterClasses([TForm1]); TheClass := GetClass('T' + FormName); if (TheClass = nil) then   exit; if TheClass.InheritsFrom(TForm)  then begin    aForm := Tform(TheClass.Create).Create(nil);    try      aForm.ShowModal;      result:=true;    finally      FreeAndNil(aForm);    end; end;end;exportsshowform;beginend.



....procedure  RunDllForm(const DllFileName,DllFormName:String;const methodName:string);typeTRunForm=function(formname:string):boolean;stdcall;var  RunForm: TRunForm;  GetDllHWND: HWND;begin  GetDllHWND := LoadLibrary(PChar(DllFileName));  try    if GetDllHWND < 32 then    begin      MessageBox(0, Pchar('沒有找到'+DllFileName+'DLL文件!'),'加載DLL失敗', MB_OK);      Exit;    end;    @RunForm := GetProcAddress(GetDllHWND,pchar(methodName));    if @RunForm <> nil then       try         RunForm(DllFormName);       except         raise Exception.Create('對不起,找不到T' + DllFormName+ '窗體!');       end     else     raise Exception.Create('無效的方法名調用');  finally    FreeLibrary(GetDllHWND);  end;end;procedure TForm1.Button1Click(Sender: TObject);beginRunDllForm('project1.dll','form1','showform');end;....


上一篇:程序間參數傳遞

下一篇:鉤子(HOOK)機制的使用

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 岳阳县| 佛冈县| 霍城县| 祁门县| 永兴县| 广灵县| 唐海县| 江陵县| 木兰县| 电白县| 千阳县| 介休市| 东安县| 东乡| 长海县| 长海县| 拉孜县| 自贡市| 富阳市| 台湾省| 廉江市| 英吉沙县| 临沧市| 祁门县| 涟源市| 和田县| 木兰县| 漳平市| 陕西省| 秭归县| 赤壁市| 靖西县| 中江县| 南城县| 南康市| 右玉县| 思南县| 中牟县| 罗城| 随州市| 曲松县|