如何完全释放DLL窗体?让他再次打开时还和第一次一样
dll里的数据集组件共享的exe的数据连接,现在是第一次运行都很正常,但关闭后再打开查询,就各种问题了。
----------------------------------------------------
调用dll打开dllform
procedure TMainFrm.N11Click(Sender: TObject);begin uPublicMethod.OpenDllFrm('BatchWageRecord.dll', '');end;function OpenDllFrm(DllName, Str: string): string;var DllHandle: THandle; ShowFrm: TShowFrm;begin Result := ''; DllHandle := LoadLibrary(PAnsiChar(DllName)); if DllHandle <> 0 then begin @ShowFrm := GetProcAddress(DllHandle, 'ShowFrm'); if @ShowFrm <> nil then ShowFrm(Application.Handle, DataModule1.conDB, Str) else begin WriteWorkLog('加载 ' + DllName + ' 函数ShowFrm失败。', Dosp_GetSysTime); Result := '打开窗体失败!'; end; end else begin WriteWorkLog('未找到' + DllName + ' ,加载失败。', Dosp_GetSysTime); Result := '加载 ' + DllName + ' 失败!'; end;end;procedure ShowFrm(AHandle: THandle; Con: TADOConnection; Str: string); stdcall; procedure GetUserInfo; var CharPos: Integer; begin CharPos := Pos('#', str); UserID := Copy(Str, 1, CharPos - 1); UserPassword := Copy(Str, CharPos + 1, Length(str) - CharPos); end;var PerQueryFrm: TPerQueryFrm;begin Application.Handle := AHandle; PerQueryFrm := TPerQueryFrm.Create(nil); DataModule2 := TDataModule2.Create(nil); GetUserInfo; DataModule2.qry_DynamicQuery.Connection := Con; DataModule2.sp_GetSysTime.Connection := Con; DataModule2.qry_GetSalary.Connection := Con; DataModule2.sp_GetWageHistory.Connection := Con; PerQueryFrm.ShowModal;end;