到目前为止,使用 QtIFW-1.5.0,我能够在 Windows 上为我的 Qt 应用程序生成在线安装程序。安装程序从我的 Web 服务器下载适当的包并执行控制脚本 installscript.qs 中定义的一些操作,例如将一些键写入注册表并创建带有图标的桌面快捷方式:
安装脚本.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 获取此值?我读了——我说了更多:研究了——文档组件 QML 类型和安装程序 QML 类型,我没有找到任何对版本的引用,除了:
安装程序 QML 类型:
boolean versionMatches(string version, string requirement)
这对我来说没用,因为你必须知道版本,这正是我发现的。
所以任何帮助将不胜感激。