Inno Setup [注册表]-使用函数返回值 [英] Inno Setup [Registry] - Using function return value

查看:53
本文介绍了Inno Setup [注册表]-使用函数返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,是否有 ValueData (或类似属性)的函数的返回值.尝试了以下内容:

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;

但这只是将字符串 GetComputerNameString()添加到注册表项.

But this simply adds the string GetComputerNameString() to the registry item.

推荐答案

使用脚本化常量,语法为 {code:FunctionName} .尽管脚本化常量函数必须采用字符串参数(即使实际实现不需要任何参数).因此 GetComputerNameString 不兼容.您必须创建一个代理功能.

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; 


有关更复杂的示例,请参见 Inno Setup [Code]部分变量为[Registry] .

这篇关于Inno Setup [注册表]-使用函数返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆