Cosmin
Cosmin

Reputation: 2404

How to automatically determine the path of previous installation using Inno Setup

I'm trying to create a inno setup installer that patches a previous installation but i can't manage to force my installer determine the path where my previous installation is. I tried using the DefaultDirName={reg:HKxx\SubkeyName,ValueName|DefaultValue} feature from inno but i'm not sure what to put in the DefaultValue's place. How can i do that?

Edit: i tried also this part:

[Setup]
DefaultDirName={code:GetPathInstalled}
[Code]
function GetPathInstalled (Param: String): String;
var
  Country: String;
begin
  RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\JoWooD\Painkiller Resurrection', 'Install', Country); 
end;

But when i run the installer the path is empty.

Upvotes: 4

Views: 2539

Answers (1)

mirtheil
mirtheil

Reputation: 9192

Your code should look like:

[Code]
function GetPathInstalled (Param: String): String;
var
  Country: String;
begin
  RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\JoWooD\Painkiller Resurrection', 'Install', Country); 
  Result:= Country;
end;

The return value from the RegQueryStringValue wasn't being returned as the result of the GetPathInstalled function.

Upvotes: 6

Related Questions