问题
I need a global string variable in Inno Setup, that is going to be initialized in [Code]
section and used in [Run]
section.
Is this possible?
回答1:
You are probably looking for a scripted constant:
[Run]
Filename: "{app}\MyProg.exe"; Parameters: "{code:GetGlobalVariable}"
[Code]
var
GlobalVariable: string;
function GetGlobalVariable(Param: string): String;
begin
Result := GlobalVariable;
end;
function InitializeSetup(): Boolean;
begin
GlobalVariable := '/parameter';
Result := True;
end;
For a more real-life example, see Use a part of a registry key/value in the Inno Setup script.
来源:https://stackoverflow.com/questions/33974745/using-global-string-script-variable-in-run-section-in-inno-setup