Search code examples
delphicrystal-reportsvcl

Crystal Reports VCL for Borland can find CRPE32.dll but none of the supporting dlls


I wanted to bring an old Delphi application (built in Borland Delphi 6) up to version 13 of Crystal reports. It had been brought up to version 10.2 before using the steps outlined in the do-it-yourself guide SAP has posted: http://scn.sap.com/docs/DOC-11048

I committed the same changes again, pointing from the 10.2 registry keys to the 13 registry keys and updating the version checks in the VCL. The VCL component now pulls CRPE32.dll successfully from the right location but then fails to find the related Dll files such as pvlocal-1-0.dll and local_fallback-4-0.dll. If I move all the Dlls to the same folder as the application they are found, but I don't know if I want to be packing all 16 dlls and a license file together with the application.

I've narrowed the issue to the LoadLibrary call in the following method. Unfortunately I can't find any information on how to resolve the issue and was hoping the community might know a way to fix it:

     function TCrpeEngine.PELoadCrpeDll(const CrpeLocation: string) : Bool;
var
  s1,s2 : string;
begin
  Result := False;
  s1 := Trim(CrpeLocation);
  CRDEngine := LoadLibrary(PChar(s1));
  {If an error occured, set the flag}
  if (CRDEngine < HINSTANCE_ERROR) then
  begin
    CRDEngine := 0;
    s2 := SysErrorMessage(GetLastError);
    if Trim(s2) = '' then
      s1 := CRD_ERROR_LOADING + Chr(10) + 'Windows Error Number: ' + IntToStr(GetLastError)
    else
      s1 := CRD_ERROR_LOADING + Chr(10) +
        'Windows Error Number: ' + IntToStr(GetLastError) + ' - ' + Trim(s2);
    CRDEngineError(s1);
  end
  else
    Result := True;
end;

Solution

  • The problem is that the the CRPE32.dll is loaded but it does not know where the other DLLs are located as they are not in the search path.

    You have a few options.

    1. You can call SetDLLDirectory with with the path that you are storing the DLLs in.
    2. Add the directory where the files are located to the system path.
    3. Add the files to a directory already in the search path.
    4. Add the files to your working directory.