I have a Delphi DLL that exports 'ShowFormModal'.
In the DLL, I have the following:
procedure ShowFormModal( reg, firstImg, secondImg, inifile: PChar; mode: Integer );stdcall;
exports ShowFormModal,
procedure ShowFormModal( reg, firstImg, secondImg, inifile: PChar; mode: Integer ); begin Form := TForm.Create( Application ); try Form.Showmodal; finally Form.Free; end; end;
in my host application, I declared the following:
type TShowFormModal = procedure( reg, firstImg, secondImg, inifile: PChar; mode: Integer);stdcall;
and I call the DLL procedure like so:
if (FileExists( IncludeTrailingBackSlash( FAppPluginFolder ) + 'Flexo.BOB')=True) then begin if ImageDLLHandle = 0 then ImageDLLHandle := LoadLibrary( PChar(IncludeTrailingBackSlash( FAppPluginFolder ) + 'Flexo.BOB') ); if ImageDLLHandle <> 0 then begin try @ShowFormModal := GetProcAddress(ImageDLLHandle, 'ShowCompareFormModal');
if (@ShowFormModal <> nil) then begin ShowFormModal( PChar(FRegisteredCompany), PChar(Trim(FImageFirstImage)), PChar(Trim(FImageSecondImage)), PChar(FcIniFileName), APP_INTEGRATED ); end; finally FreeLibrary( ImageDLLHandle ); ImageDLLHandle := 0; end; end; end;
Both the host and the DLL are compiled with packages and Sharemem. The host program freezes on 'FreeLibrary' or complains that the handle is invalid.
Where did I go wrong? Any help is greatly appreciated.
Andy