[Files]
Source: \"C:\\MyProg.exe\"; DestDir: \"{app}\"; BeforeInstall: GetHome(); Flags: ignoreversion
[INI]
Filename: \"{myVarFromPascal}\\.MyProg\\settings.ini\";
You will need to change your variable to be in the global scope and write a simple getter function for so called scripted constant:
[Files]
Source: "C:\MyProg.exe"; DestDir: "{app}"; BeforeInstall: GetHome; Flags: ignoreversion
[INI]
Filename: "{code:GetMyVar}\.MyProg\settings.ini"; Section: "Settings"; Key: "sound"; String: "1"; Flags: createkeyifdoesntexist
[Code]
var
myPascalVar: string;
function GetMyVar(Value: string): string;
begin
Result := myPascalVar;
end;
procedure GetHome;
begin
RegQueryStringValue(HKEY_CURRENT_USER, 'Volatile Environment', 'USERPROFILE', myPascalVar);
MsgBox('Value is "' + myPascalVar + '"', mbInformation, MB_OK);
end;