【问题标题】:Qt Installer Framework - Reading downloaded package versionQt Installer Framework - 读取下载的包版本
【发布时间】: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 Typeinstaller QML Type,我没有找到任何版本参考,除了:

安装程序 QML 类型:

boolean versionMatches(string version, string requirement)

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

因此,我们将不胜感激。

【问题讨论】:

    标签: c++ qt qt-installer


    【解决方案1】:

    你可以打电话

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

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

    【讨论】:

    • 谢谢,它有效。您有任何关于可从安装脚本访问的变量的快速指南吗?
    • 这个文档我看了几十遍都没看!谢谢。
    • 嗯,它有效,但不如预期。我需要下载包的 PACKAGE 版本,每次更新都会改变。 ProductVersion 不会随更新而改变,因为它依赖于安装程序创建的维护工具。
    猜你喜欢
    • 2019-01-28
    • 1970-01-01
    • 2014-02-09
    • 1970-01-01
    • 1970-01-01
    • 2014-02-18
    • 2016-01-25
    • 2017-01-04
    • 2016-05-11
    相关资源
    最近更新 更多