library Project; { 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, Windows, Forms, UnitC in 'UnitC.pas' {FormC}; {$R *.res} var DllApp: TApplication; function ShowCForm(App: TApplication): Boolean; stdcall; begin Application :=App;{获取调用窗体的Application,显而易见的功能是 能使你的窗体融合到调用程序中。通过它还能进行很多操作} Formc:= TFormc.Create(App); FormC.Show; end; procedure GetParam(var Value: string); stdcall; {通过函数的方式,返回C窗体中的Param得到} begin Value:= FormC.Param;{Param在FormC中定义为全局变量} end; procedure UnLoadForm(Reason: Integer); register; begin {DLL取消调用时,发送DLL_PROCESS_DETACH消息,此时将DLL的Application返回为本身} if Reason = DLL_PROCESS_DETACH then Application:=DLLApp; end; exports ShowCForm, GetParam; begin DLLApp:=Application;{初始化时保存DLL本身Application,以便DLL取消时返回} DLLProc := @UnLoadForm; end.