How to write install path to registry after instal

2019-02-22 15:19发布

问题:

How to write install path to registry after install is complete with Inno sSetup?

Thanks in advance!

回答1:

Like TLama said, you can achieve it via ssPostInstall if you want the key to be added after the installation process is complete.

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep=ssPostInstall then begin
     RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\HHSTECH',
    'InstallPath', ExpandConstant('{app}'));
  end;
end;

Or you can use AfterInstall that will be called after the last files is installed (copied).

[Files]
Source: ".\THEVERYLASTFILE.XXX"; DestDir: "{app}"; AfterInstall: MyAfterInstall

[Code]
procedure MyAfterInstall();
begin
     RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\HHSTECH',
    'InstallPath', ExpandConstant('{app}'));
end;


回答2:

[Registry]
Root: HKLM; Subkey: Software\HHSTECH; ValueType: string; ValueName: InstallPath; ValueData: {app}


标签: inno-setup