在[注册表]部分中获取文件版本号 [英] Getting a file version number in the [Registry] section

查看:139
本文介绍了在[注册表]部分中获取文件版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用inno设置为Visual Studio项目创建安装程序.我遇到了一个错误

I am creating an installer for a visual studio project using inno setup. I am getting an error for

"Parameter ValueData has invalid value"

此代码:

[Code]
function GetVersion(AppVersion: String): String;
var
  Version: String;
  CharIndex: integer;
  c: char;
begin  
for CharIndex := 1 to Length(AppVersion) do begin
    c := AppVersion[CharIndex];
    if (c <> '.') then
    Version := Version + c;
end;
Result := Version;
end;

[Registry]
Root: HKCU; Subkey: "MyCompany\Product"; ValueType: DWORD ; ValueName: "Version" ;     ValueData: GetVersion({#MyAppVersion}); Flags: uninsdeletekey;

我具有这样的版本控制:"1.0.0.3、1.0.0.4等".因此,该程序将删除.并将它们全部连接起来以形成一个数字,应将其传回以写入注册表.因此,我可以检查此注册表值,然后卸载或更新以前的版本.我听说有人说inno会自动升级,但是我创建了带有名称和版本号的图标.预先感谢.

I have versioning like this "1.0.0.3, 1.0.0.4, etc". So this program removes . and concatenates all of them to form a number and should pass back to write to registry. So, I can check this registry value and uninstall or update the previous version. I heard someone saying inno would upgrade automcatically, but I create icons with their name with version number. Thanks in advance.

推荐答案

您看到的问题是因为要在InnoSetup的主要部分中将函数作为参数调用,您需要使用{code:}构造. br> 这是一个对我有用的例子:

The problem you are seeing is because to call a function as a parameter in the main sections of InnoSetup, you need to use the {code:} construct.
Here's an example that worked for me:

[Registry]
Root: HKCU; Subkey: "Software\MyCompany\Product"; ValueType: DWORD ; ValueName: "Version" ;     ValueData: {code:GetVersion|{#MyAppVersion}}; Flags: uninsdeletekey;

这篇关于在[注册表]部分中获取文件版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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