Cha*_*iga 4 windows delphi shellexecute
我在 windows vista 中使用了“ ShellExecute ”函数
有没有办法将输出通过管道传输到文件?
IE
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 中使用重定向器 simbol ">",但使用 Windows 命令解释器 cmd.exe。
试试这个样本
ShellExecute(0,nil,'cmd.exe','/c MySqlDump.exe -u user1  -ppassword  dbName > TheOutputFile.Sql',nil,sw_normal);
另一种选择是使用管道,您可以在此链接中找到一个非常好的示例。