我在 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/