[Files]
Source: "C:\MyProg.exe"; DestDir: "{app}"; BeforeInstall: GetHome(); Flags: ignoreversion
[INI]
Filename: "{myVarFromPascal}\.MyProg\settings.ini"; Section: "Settings"; Key: "sound"; String: "1"; Flags: createkeyifdoesntexist
[Code]
procedure GetHome();
var
myPascalVar: String;
begin
RegQueryStringValue(HKEY_CURRENT_USER, 'Volatile Environment','USERPROFILE', myPascalVar);
MsgBox('Value is "' + myPascalVar + '"', mbInformation, MB_OK);
end;
These are my three example sections in INNO Setup. I want to use myPascalVar
in the INI Section. How can I do it?
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With