Inno Setup: Is there any way to set a registry key value when uninstalling?

inno-setup

Solution

You can use specific `RegWrite` function (for `DWord`, `Binary`, `StringValue`, etc) in `procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);` with `usPostUninstall` or `usDone`

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  if CurUninstallStep = usPostUninstall then
    RegWriteStringValue(HKEY_CURRENT_USER, 'Software\My Company\My Program',
      'UserName', ExpandConstant('{sysuserinfoname}'));
end;

Problem

I know how to have Inno Setup create/manipulate registry keys and/or values on install and I know that you can delete a value, a key, etc when uninstalling. But is there any way to have Inno Setup actually change the value of a key when the uninstall process is done? The setup I'm creating changes the value of a dword key that another application uses to a value to 1, indicating it's installed, and when this application is removed I need the value to be restored to 0, indicating it's removal. Is this possible, without deleting the actual key/value?

Original source