gpt4 book ai didi

c++ - Qt Installer Framework - 读取下载的包版本

转载 作者:行者123 更新时间:2023-11-30 05:45:02 25 4
gpt4 key购买 nike

使用 QtIFW-1.5.0,到目前为止,我能够为 Windows 上的 Qt 应用程序生成在线安装程序。安装程序从我的 Web 服务器下载适当的包并执行控制脚本 installscript.qs 中定义的一些操作,例如将一些 key 写入注册表并创建带有图标的桌面快捷方式:

安装脚本.qs:

Component.prototype.createOperations = function()
{
try
{
// call the base create operations function
component.createOperations();

// Add some keys to registry;
var userProfile = installer.environmentVariable("USERPROFILE");
installer.setValue("UserProfile", userProfile);
var reg = installer.environmentVariable("SystemRoot") + "\\System32\\reg.exe";
var key= "HKCU\\Software\\Company\\Product";
component.addOperation("Execute", reg, "ADD", key, "/f");
component.addOperation("Execute", reg, "ADD", key, "/v", "productId", "/t", "REG_BINARY");

// Add a desktop shortcut with icon:
component.addOperation("CreateShortcut",
"@TargetDir@\\MyExecutable.exe",
"@UserProfile@\\Desktop\\MyExecutable.lnk",
"workingDirectory=@TargetDir@",
"iconPath=@TargetDir@\\MyIcon.ico");
}
catch (e)
{
print(e);
}
}

好吧,但我需要写入注册表的另一个键是包版本号,在安装程序配置文件 config.xml 中定义的标签

<Version></Version>

如何从 installscript.qs 获取这个值?我读了——我会说更多:研究过——文档 component QML Typeinstaller QML Type我没有找到任何版本引用,除了:

安装程序 QML 类型:

boolean versionMatches(string version, string requirement)

这对我没用,因为你必须知道版本,这正是我找到的。

因此,我们将不胜感激。

最佳答案

你可以打电话

var version = installer.value("ProductVersion");

获取 config.xml 文件中指定的版本。

关于c++ - Qt Installer Framework - 读取下载的包版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29534048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com