Writing 32/64-bit specific registry key at the end of the installation in Inno Setup

你说的曾经没有我的故事 提交于 2019-12-01 11:47:30

To execute a code after an installation finishes, use the CurStepChanged event function and check for CurStep = ssPostInstall.

As Inno Setup is 32-bit application, by default it automatically gets redirected to the Wow6432Node on 64-bit systems. No need to do that explicitly. So if the Wow6432Node is the only difference between the 32-bit and 64-bit path, you do not to do anything special:

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
  begin
    Log('Installation finished, writing connection string');
    RegWriteStringValue(
      HKEY_LOCAL_MACHINE, 'SOFTWARE\A', 'ConnectionString', 'Data Source=Test;');
  end;
end;

Of course, unless you use 64-bit installation mode.

See also: Writing 32/64-bit specific registry key in Inno Setup.


If the key path really differs, use the IsWin64 function:

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
  begin
    if IsWin64 then
    begin
      Log('Installation finished, writing 64-bit connection string');
      RegWriteStringValue(
        HKEY_LOCAL_MACHINE, 'SOFTWARE\A', 'ConnectionString', 'Data Source=Test;');
    end
      else
    begin
      Log('Installation finished, writing 32-bit connection string');
      RegWriteStringValue(
        HKEY_LOCAL_MACHINE, 'SOFTWARE\B', 'ConnectionString', 'Data Source=Test;');
    end;
  end;
end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!