0
votes

I need to force the directive CreateUninstallRegKey in the [Setup] Section to only create the Registry Key for uninstall when needed.

For example , if I set a condition to create Uninstall Registry Key, it must only be created when the condition goes True. Otherwise the Uninstall Registry Key must not be created.

How can I do this in Inno Setup?

UPDATED QUESTION

The code I wrote is:

[Setup]
CreateUninstallRegKey=RegKeyDeterminer

[Code]
function RegKeyDeterminer(): Boolean;
  begin
  Result:= ISDoneError = True;
  if ISDoneError = True then Result:= True;
end;

With this code , The Uninstall Registry Key is always creating. (It should be something wrong in the code I wrote.)

The Uninstall Registry Key must not be created if ISDoneError = True.

The Uninstall Registry Key must be created if ISDoneError = False.

ISDoneError only has True or False values.(It is a Boolean Function in ISDone.dll which is a Dynamic Link Library that used to extract files from 7-Zip,RAR,Binary etc. archives in Inno Setup.)

These are the conditions. If you can see any mistakes or condition setting errors , then correct my code.

Thank You.

1
"If I set a condition" - What condition? Can you give us an example when you need to create the key, and when not? - Martin Prikryl
Okay without giving you my condition, I made my work worst. See my UPDATED QUESTION. - GTAVLover
Your solution to error handling does not look right. You should not allow the installer to even finish, when something goes wrong. Not hack it by pretending that the installer did not finish. - Martin Prikryl
So should I remove the line if ISDoneError = True then Result:= True from it to resolve this wrong behaviour? - GTAVLover

1 Answers

2
votes

The CreateUninstallRegKey directive can take a boolean expression/function as its value.

So just implement the function to return True when you need to create the key and False otherwise.

 [Setup]
 CreateUninstallRegKey=CreateKey

 [Code]

 function CreateKey: Boolean;
 begin
   Result := condition;
 end;