delphi 能實現把別的DLL的窗體句柄查到後,貼到PANL之中,此類文章網上很多,而若是是delphi不一樣版本開發的DLL互調時,一些控件內部的定義有所區別,由於沒法(至少目前我以爲理論上不可行)實現不一樣版本的DLL融合一體式的共用同一個appcation.app
所以,跨版本的DLL調用,實際上也就是把DLL當作一個獨立程序,而數據鏈接這些須要在DLL中本身再實現一套,會有必定的麻煩,可是若是不得不這樣作,這樣的犧牲也是沒辦法的事(若是誰實現了協調的跨版本數據鏈接共享,但願留言指點一二)函數
Function GETInterfacedFunc(iApplication:TApplication;iScreen: TScreen;Imode:integer;Userinfo:String):IInterfacedFunc ;stdcall;
上面的代碼,是常規的DELPHI 的DLL調用實現,也就是傳入 orm
iApplication:TApplication;iScreen: TScreen; 而後返回調用接口。
Function GETInterfacedFunc(Imode:integer;Userinfo:String):IInterfacedFunc ;stdcall;
跨版本至關於獨立的程序調用,所以入口函數,就不能再處理 Application與 Screen了,咋們,就當這個DLL是一個獨立EXEblog
加載DLL後接口
下面就是顯示窗體了開發
直接上代碼吧it
function Tform.Showform(Parent: THandle;PHeight:integer;PWidth:integer ): boolean; begin frm:=TfrmMain.Create(nil); // DM:=TDM.Create(application); //application if WINAPI.Windows.SetParent(frm.Handle,Parent)=0 then begin Result:=False; frm.Free; Exit; end; SetWindowLong(frm.Handle,GWL_STYLE,GetWindowLong(frm.Handle,GWL_STYLE) and not (WS_CAPTION or WS_THICKFRAME)); // //WS_CAPTION和WS_THICKFRAME分別表示標題欄和邊框 WINAPI.Windows.MoveWindow(frm.Handle,0,0,PWidth,PHeight,True); frm.Show; end;
使用winAPI 來實現窗體的處理,比直接用delphi 常規代碼,更具備兼容性。io
外部EXE中的調用代碼,我想不須要特別列出,其實與同版本調用,已是完樣同樣的了。function
就是普通的接口調用了form
IInterfacedFunc=interface ['{1440EC99-A782-4E12-9F82-3020C8D887B4}'] Function Showform(Parent: THandle;PHeight:integer;PWidth:integer):boolean;stdcall; procedure Resize(PHeight:integer;PWidth:integer);stdcall; procedure CloseForm ;stdcall; procedure SetCloseProc(Proc:TCloseProc);stdcall; end;
附:接口pas代碼。