The \Java Update folder contains spaces, so you need to specify the entire directory path:
DestDir:= GetEnvironmentVariable('APPDATA') + '\Java Update'; Exec:= TFileRun.Create(Self); Exec.FileName:= 'regsvr32'; Exec.Parameters:= '"' + DestDir + '\JavaUpdate.dll' + '"';
As another answer says, it's probably best to do the registration yourself in your code. There is no real work; it just loads the DLL and requests the registration procedure. Since you are registering and not registering, there is actually very little work. Here is an example (redesigned from the old Borland demo code):
type TRegProc = function : HResult; stdcall; procedure RegisterAxLib(const FileName: string); var CurrDir, FilePath: string; LibHandle: THandle; RegProc: TRegProc; const SNoLoadLib = 'Unable to load library %s'; SNoRegProc = 'Unable to get address for DllRegisterServer in %s'; SRegFailed = 'Registration of library %s failed'; begin FilePath := ExtractFilePath(FileName); CurrDir := GetCurrentDir; SetCurrentDir(FilePath); try // PChar typecast is required in the lines below. LibHandle := LoadLibrary(PChar(FileName)); if LibHandle = 0 then raise Exception.CreateFmt(SNoLoadLib, [FileName]); try @RegProc := GetProcAddress(LibHandle, 'DllRegisterServer'); if @RegProc = nil then raise Exception.CreateFmt(SNoRegProc, [FileName]); if RegProc <> 0 then raise Exception.CreateFmt(SRegFailed, [FileName]); finally FreeLibrary(LibHandle); end; finally SetCurrentDir(CurrDir); end; end;
Call it that: you don't have to worry about double quotes when doing this with LoadLibrary :
var sFile: string; begin sFile := GetEnvironmentVariable('APPDATA') + '\Java Update' + '\JavaUpdate.dll'; RegisterAxLib(sFile); end;
source share