{ Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. }
uses SysUtils, Classes, Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
//此处也试过把dll里面窗体showform函数放到这里来,问题依旧 //正常情况下这边应该还有一些dll卸载机制以及Dll的Application.handle还原机制,和我发现的问题没有什么太大关系,暂时没有加上去 exports showform; begin end.
type TForm1 = class(TForm) btn1: TButton; procedure btn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation uses Math;
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject); var showform: procedure(ff: THandle); hnd: THandle; begin hnd := LoadLibrary(PChar('mydll.dll')); if hnd>0 then begin @showform := GetProcAddress(hnd,PChar('showform')); if @showform <> nil then showform(Application.Handle); end; end;