Is there anyway to have the return value of a function for the ValueData
(or similar property). Tried the following:
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
ValueType: string; ValueName: "Hostname"; ValueData: GetComputerNameString(); \
Flags: preservestringtype;
But this simply adds the string GetComputerNameString()
to the registry item.
Use a scripted constant, with syntax {code:FunctionName}
. Though the scripted constant function must take a string parameter (even if the actual implementation does not need any parameter). So the GetComputerNameString
is not compatible. You have to create a proxy function.
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
ValueType: string; ValueName: "Hostname"; ValueData: {code:GetComputerName}; \
Flags: preservestringtype;
[Code]
function GetComputerName(Param: string): string;
begin
Result := GetComputerNameString;
end;
For a more complex example, see Inno Setup [Code] section variable to [Registry].