windows - 使用 windows ‘ShellExecute’ 函数将数据通过管道传输到文件

标签 windows delphi shellexecute

我在 windows vista 中使用“ShellExecute”函数

有什么方法可以将输出通过管道传输到文件吗?

MySqlDump.exe '-u user1 -ppassword dbName > TheOutputFile.Sql

这是我的代码

theProgram     :=  'MySqlDump.exe';
itsParameters  :=  '-u user1  -ppassword  dbName';
rslt := ShellExecute(0, 'open',
                       pChar (theProgram),
                       pChar (itsParameters),
                       nil,
                       SW_SHOW);

编辑:

我试过了

 itsParameters  :=  '-u user1  -ppassword  dbName > TheOutputFile.Sql';

但这行不通

最佳答案

@Charles,您可以在 ShellExecute 中使用重定向符号“>”,但使用 Windows 命令解释器 cmd.exe。

试试这个例子

ShellExecute(0,nil,'cmd.exe','/c MySqlDump.exe -u user1  -ppassword  dbName > TheOutputFile.Sql',nil,sw_normal);

另一个选项是使用管道,你可以在这个 link 中找到一个很好的例子.

关于windows - 使用 windows ‘ShellExecute’ 函数将数据通过管道传输到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2093818/

相关文章:

android - 在 React Native 项目中安装任何附加包后无法识别命令 `run-android`

delphi - COM dll 注册时收到错误 80004005

delphi - 需要 Delphi 和 ADOTable 过滤方面的帮助

perl - 我可以从 Perl 捕获 shell 调用吗?

delphi - 使用shellexecute时 "printto"的参数是什么?

regex - Notepad++ 用获取一些文本替换文本

windows - 如何防止 Windows XP 窃取我用于 Emacs 的输入 Ctrl-Space?

windows - Inno Setup 安装程序的文本编码错误

delphi - 如何从 THtmlViewer 对象复制和粘贴?

java - 如何从另一个路径执行脚本