【发布时间】:2015-04-09 08:57:45
【问题描述】:
使用 QtIFW-1.5.0,到目前为止,我能够在 Windows 上为我的 Qt 应用程序生成在线安装程序。安装程序从我的 Web 服务器下载适当的包并执行控制脚本 installscript.qs 中定义的一些操作,例如将一些键写入注册表并创建带有图标的桌面快捷方式:
installscript.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);
}
}
好的,但是我需要写入注册表的另一个键是包 VERSION NUMBER,在安装程序配置文件 config.xml 的标签中定义
<Version></Version>
如何从 installscript.qs 获取此值?我读过——我说了更多:研究过——文档component QML Type 和installer QML Type,我没有找到任何版本参考,除了:
安装程序 QML 类型:
boolean versionMatches(string version, string requirement)
这对我没用,因为你必须知道版本,这正是我发现的。
因此,我们将不胜感激。
【问题讨论】:
标签: c++ qt qt-installer