我正在创建一个安装程序,我需要具有读取文本文件并获取一些安装参数的功能。具体来说,我需要从文本文件中读取安装路径。我试图从 JS 使用 FileReader,但我不知道如何在Controller.prototype.TargetDirectoryPageCallback
函数内部使用它。也许有更简单的方法来做到这一点?任何工作样本可能吗?
问问题
1003 次
2 回答
1
脚本上下文只有几个对象。
- 安慰
- QFileDialog
- 打印
- qsTr
- 系统信息
- 安装程序
- 纽扣
- QMessageBox
- QDesktopServices
- 安装程序
- 桂
“安装程序”对象是最重要的一个(参见http://doc.qt.io/qtinstallerframework/scripting-installer.html#execute-method)。借助此执行方法,您可以在系统上运行任何应用程序。所以这里是我未经测试的代码建议:
if (installer.value("os") == "win") {
var windir = installer.environmentVariable("WINDIR");
if (windir == "")
print("Could not find windows installation directory.");
var cmdLocation = windir + "\\system32\\cmd.exe";
var fileContent = installer.execute(cmdLocation, new Array("/c", "type", <your_file>))[0];
是的,这不是很舒服——所以也许你应该创建一个功能请求或将这种功能添加到安装程序框架中。
于 2015-11-18T10:01:49.617 回答
1
Qt 安装程序框架 3.x:
string readFile(string filePath, string codecName)
于 2019-10-07T09:55:14.160 回答