I'm using Inno Setup for my installation and am adding the following function to the existing [Code]
section:
function Get64Or32: String;
begin
if IsWin64 then
begin
Result := 'Program Files (x86)';
end
else
begin
Result := 'Program Files';
end;
end;
I keep getting the following error:
10:41:08 Invalid prototype for 'Get64Or32'
I have tried several permutations including having the parenthesis after the function name but get the same error each time.
I'm attempting to use this from the [Registry]
section to pinpoint the Java location:
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType:string; ValueName:"JRE_HOME"; ValueData:"C:\{code:Get64or32}\Java\jre_1.8.0_151"; Flags: preservestringtype uninsdeletevalue uninsdeletekeyifempty; Permissions: users-modify;
If you look here Pascal Scripting: Scripted Constants it explains it all. To quote:
The syntax of a
{code:...}
constant is:{code:FunctionName|Param}
The Pascal script can contain several functions which are called when Setup wants to know the value of a scripted
{code:...}
constant. The called function must have 1String
parameter namedParam
, and must return aString
or aBoolean
value depending on where the constant is used.The syntax of a
{code:...}
constant is:{code:FunctionName|Param}
It also provides:
[Code]
function MyConst(Param: String): String;
begin
Result := ExpandConstant('{autopf}');
end;
[INI]
FileName: "{app}\MyIni.ini"; Section: "MySettings"; Key: "ShortApp"; String: "{code:GetShortName|{app}}"
You don't have to use the parameter but it must be part of the prototype.