How to register a 64-bit dll (on a 64-bit OS) from a 32-bit application

I am currently using the following function to register a DLL that handles context menu calls.

function RegisterLibrary(szLibrary: String): Integer;
var
  hLib: THandle;
  drs: TDllRegisterServer;
begin
  // Attempt to load the library
  hLib := LoadLibrary(PChar(szLibrary));

  // Handle check
  if IsHandle(hLib) then
  begin // Get the register function
    @drs := GetProcAddress(hLib, LIB_REGISTER);

    if Assigned(@drs)
      then Result := drs            // Make the function call
      else Result := GetLastError;  // Return last error

    // Unload the library
    FreeLibrary(hLib);
  end else
    Result := GetLastError; // Return last error
end;

Unfortunately, this does not work when trying to register a 64-bit dll from my 32-bit application.

Is there an alternative to registering my 64-bit dll (compiled with free Pascal) from my 32-bit application (compiled in Delphi)?

I suppose I can call C: \ Windows \ system \ regsvr32.exe "/ s" file name ", but would like to know if I have another alternative.

Thanks!

+3
source share
2 answers

, 32- 64- dll. 64- , DLL .

+7

64- , 32- Delphi 64- DLL .

, Inno Setup. Visual Studio 64- , Helper.pas , HelperRegisterTypeLibrary(), .

+4

Source: https://habr.com/ru/post/1718087/


All Articles