I\'ve recently started using Inno Setup to try and create a simple .exe installer for a game modification.
I\'ve got the installer working fine for the most part, bu
You can assign value of a DefaultDirName directive through the [Code] section. For instance, the following pseudo-script shows how to query two string values in registry and return the first found to the DefaultDirName directive. If none of the queried registry values is found, a default constant value is returned:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={code:GetDirName}
[Code]
function GetDirName(Value: string): string;
var
InstallPath: string;
begin
// initialize default path, which will be returned when the following registry
// key queries fail due to missing keys or for some different reason
Result := '{pf}\Default Dir Name';
// query the first registry value; if this succeeds, return the obtained value
if RegQueryStringValue(HKLM, 'Software\Vendor\Application', 'First Key', InstallPath) then
Result := InstallPath
// otherwise the first registry key query failed, so...
else
// query the second registry value; if it succeeds, return the obtained value
if RegQueryStringValue(HKLM, 'Software\Vendor\Application', 'Second Key', InstallPath) then
Result := InstallPath;
end;