ok, so you want this for your DefaultDirName line in the setup section
[setup]
DefaultDirName={code:GetInstallDirectory}
Then in the code section:
Code:
[C0DE]
function GetInstallDirectory(S: String) : String;
var installDirectory : String;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\SOMEKEY', 'somevalue', installDirectory) then
//SUCCESS READING VALUE
Result := installDirectory
else
//FAILED READING VALUE
Result := ExpandConstant('{pf}\my program\my program folder');
end;
You don't need to use RegKeyExists, because just querying the value fails when it doesn't exist. So if you fail, you use your default. Notice the use of Expand Constant on {pf} which will convert it to their program files directory (can't always assume Windows is on C
So I am sure you can tell, but the values you want to change here are:
'SOFTWARE\SOMEKEY'
'somevalue'
'my program\my program folder'
Think this should get you going.