- This topic has 1 reply, 2 voices, and was last updated 4 months, 1 week ago by .
Viewing 1 reply thread
Viewing 1 reply thread
- You must be logged in to reply to this topic.
Tagged: kbmMWGlobal DLL Hang
Hi Kim,
We noticed that when the kbmMWGlobal is included in the uses of a DLL the application that uses the DLL will hang when it tries to unload it.
DLL Code:
library DllWithKbmMw;
{KbmMw source folder is in search path of project}
uses
kbmMWGlobal;
{$R *.res}
begin
end.
Exe Code:
unit Main;
{
Unloading DllWithKbmMw.dll is hanging.
}
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TMainForm = class(TForm)
LoadBtn: TButton;
UnloadBtn: TButton;
procedure LoadBtnClick(Sender: TObject);
procedure UnloadBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FDllH: THandle;
procedure UpdateButtons;
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
uses
System.UITypes;
procedure TMainForm.FormCreate(Sender: TObject);
begin
UpdateButtons;
end;
procedure TMainForm.LoadBtnClick(Sender: TObject);
var
DllFn: string;
begin
if FDllH=0 then
begin
DllFn:=IncludeTrailingPathDelimiter(ExtractFileDir(Application.ExeName))+
'DllWithKbmMw.dll';
FDllH:=LoadLibrary(PChar(DllFn));
if FDllH=0 then
raise Exception.Create('Error loading DLL: '+SysErrorMessage(GetLastError));
UpdateButtons;
MessageDlg('DLL loaded',TMsgDlgType.mtInformation,[mbOk],0);
end;
end;
procedure TMainForm.UnloadBtnClick(Sender: TObject);
begin
if FDllH<>0 then
begin
FreeLibrary(FDllH);//This will hang (in kbmMWFinalize)
FDllH:=0;
UpdateButtons;
MessageDlg('DLL unloaded',TMsgDlgType.mtInformation,[mbOk],0);
end;
end;
procedure TMainForm.UpdateButtons;
begin
LoadBtn.Enabled:=FDllH=0;
UnLoadBtn.Enabled:=FDllH<>0;
end;
end.
The problem is somewhere in the finalization of the unit, but we couldn’t pinpoint where it goes wrong exactly.
Could you please look into this!
Thanks in advance!
Kind regards Luigi
I think the problem has been solved in 5.24.00 by rewriting the kbmMWDependency package and cleaning up dependencies.
/Kim/C4D