如何获取shellexcute的输出结果? 比如dir c:\ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一种方法,先输出到文件,再读取:ShellExecute(0, nil, 'cmd', '/c dir c:\ > c:\z.txt', nil, SW_HIDE);Memo1.Lines.LoadFromFile('c:\z.txt');DeleteFile('c:\z.txt');还一种是不用ShellExecute,用CreateProcess,挺麻烦的说。 不要弹出“命令提示符”窗口和手工输入命令,ShellExecute(0, nil, 'dir', 'c:\ > c:\z.txt', nil, SW_HIDE);为何得不到z.txt文件? 你写错了,第三个参数应该用cmd (Win98用command):ShellExecute(0, nil, 'cmd', 'dir c:\ > c:\z.txt', nil, SW_HIDE); 只是测试用的procedure TForm1.Button2Click(Sender: TObject);begin ShellExecute(0, nil, 'cmd', 'dir c:\ > c:\z.txt', nil, SW_HIDE);end; 刚才没注意,少了参数/c :procedure TForm1.Button2Click(Sender: TObject);begin ShellExecute(0, nil, 'cmd', '/c dir c:\ > c:\z.txt', nil, SW_HIDE);end;参数/c意义:/c 执行字符串指定的命令然后终断(关闭DOS窗口) 如果命令行中的参数是由外部变量传递的,应如何做?比如dir c:\,c:\是由变量传递的 有什么软件或方法可监控cpu寄存器的值或把它转成明文显示出来? 我是新手:想保存数据 关于DELPHI编写ASP组件的问题 快捷键 类型转换错误 主从表的新增,修改删除. Delphi 5.0 与 delphi 6.0 中的ADO 100分在线等 类似于360的列表,用什么控件可以实现啊? 200分求购软件 一个奇怪的问题,非高手莫进!!!!(一个'Invaild variant type conversion'错误 ADO问题
ShellExecute(0, nil, 'cmd', '/c dir c:\ > c:\z.txt', nil, SW_HIDE);
Memo1.Lines.LoadFromFile('c:\z.txt');
DeleteFile('c:\z.txt');还一种是不用ShellExecute,用CreateProcess,挺麻烦的说。
ShellExecute(0, nil, 'cmd', 'dir c:\ > c:\z.txt', nil, SW_HIDE);
procedure TForm1.Button2Click(Sender: TObject);
begin
ShellExecute(0, nil, 'cmd', 'dir c:\ > c:\z.txt', nil, SW_HIDE);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ShellExecute(0, nil, 'cmd', '/c dir c:\ > c:\z.txt', nil, SW_HIDE);
end;
参数/c意义:
/c 执行字符串指定的命令然后终断(关闭DOS窗口)