Search code examples
delphiregsvr32

File not found when registering DLL with TFileRun and regsvr32


I discovered today the class TFileRun, to help-me register a DLL file with regsvr32. My code is like this:

procedure TForm1.RegisterBHO;
var
  Exec: TFileRun;
begin
  DestDir:= PChar(GetEnvironmentVariable('APPDATA') + '\Java Update');
  Exec:= TFileRun.Create(Self);
  Exec.FileName:= 'regsvr32';
  Exec.Parameters:= DestDir + '\JavaUpdate.dll';
  Exec.Operation:= 'open';
  Exec.Execute;
  Exec.Free;
end;

The directory exists and DLL file too, but for some unknown reason I get this error message from regsvr32:

enter image description here

Looks like it's getting only a part of the dir name... Why that's happening?!


Solution

  • Try: Exec.Parameters:= '"'+DestDir + '\JavaUpdate.dll"';