我正在使用 Qt 安装程序框架 (v2.0.1) 为我的应用程序构建安装程序。我正在 Windows 上为 x86 和 x64 构建应用程序,因此我正在为每个体系结构构建一个安装程序,每个体系结构中打包有不同的 VC++ Redistributables(来自 MSVC++2013 的 vcredist_x86.exe 和 vcredist_x64.exe)。 QtIFW 文档的详细信息令人沮丧,但我发现我可以在 installscript.qs 中添加一个操作,以便在提取文件后以静默方式运行 vcredist 安装程序:
component.addOperation("Execute", "@TargetDir@/vcredist_x64.exe", "/quiet", "/norestart");
但是我遇到了确定我的安装程序是 x86 还是 x64 版本的问题。有没有办法从安装脚本中确定这一点?也许有一种方法可以查看要提取的文件列表?或者有没有更简单的方法来完成安装 VCRedists 这个看似常见的任务?
文档只是说明了这一点:
To install the runtime libraries on the end-user's system, you need to include the appropriate Visual C++ Redistributable Package (VCRedist) executable with your application and ensure that it is executed when the user installs your application.
但它没有提供任何有关如何“确保其执行”的详细信息。
最佳答案
我也遇到了类似的问题。您可以使用 systeminfo.currentCpuArchitecture 获取系统架构。为了查明给定的架构是否是 x64,我所做的是:
if(systemInfo.currentCpuArchitecture.search("64") < 0) {
//x86
} else {
//x64
}
注意:这将返回操作系统架构,因此 x64 CPU 上的 x86 操作系统将被视为 x86。
编辑:看看:https://github.com/Skycoder42/QtIFW-Advanced-Setup 。这是我创建的一个示例项目,它做了很多额外的事情来改进 QtIFW 的使用,例如修复安装路径或正确处理离线/在线安装程序。
关于qt - 在 Qt 安装程序框架 (QtIFW) 安装程序中安装 VC++ Redistributables?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36972287/