DLL鏈接庫(kù)代碼
興安網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、APP開(kāi)發(fā)、響應(yīng)式網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開(kāi)發(fā),運(yùn)營(yíng)維護(hù)。成都創(chuàng)新互聯(lián)成立于2013年到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來(lái)保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)。
Library Project1; uses Forms, Unit1 in 'Unit1.pas' {Form1}; Function ShowForm(AHandle:THandle):Boolean;StdCall; var AForm:TForm1; begin Result:=False; Application.Handle:=AHandle; AForm:=TForm1.Create(Application); Try AForm.ShowModal; Result:=True; Finally AForm.Free; end; end; {$R *.res} exports ShowForm; begin end.
Form中調(diào)用代碼
unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; TShowForm=Function (AHandle:THandle):Boolean;Stdcall; //001 var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var mainfrm,DllForm:THandle; //002 ShowForm:TShowForm; //003 begin mainfrm:=Form1.Handle; //004 DllForm:=LoadLibrary('hello.dll'); //005 Try begin if DllForm<>0 then begin @ShowForm:=GetProcAddress(DllForm,'ShowForm'); ShowForm(mainfrm); end else begin RaiseLastWin32Error; end; end; Finally FreeLibrary(DllForm); end; end; procedure TForm1.FormCreate(Sender: TObject); begin end; end.