这个是DOS内部命令,要用到可执行文件CMD.EXE才能实现这个操作。
如winexec('cmd /c copy c:\a.txt c:\b.txt',sw_hide)
如winexec('cmd /c copy c:\a.txt c:\b.txt',sw_hide)
解决方案 »
- 新手问题1:应该是TFORM1还是FORM1??
- data1.ADOQYygxx问题,请大侠指点。
- [无满意答案结贴]
- Delphi+Vss中的SQL问题?
- 珠三角有工厂要人的吗
- [关于菜单的问题]今天在写程序的时候,偶然看到菜单可以从MNU导入
- DLL在主线程死掉后, 如何响应其它程序?
- 弟兄门救急啊!什么地方有mathematic的下载!
- Delphi 的小问题
- 请大侠指教:如何实现象PHOTOSHOP的魔术棒的功能?(内空)
- 没人回答吗?(在Delphi中使用Excel.Application的一些问题)本人有2000分的可用分可是只能给36分为什么不知道不过一事定补分?多谢了各位大侠!
- 如何刷新透明标签
试试!
runFile: String;
SL: TStringList;
begin
RunFile := 'DosDos.bat';
SL := TStringList.Create;
SL.Add('copy c:\a.txt c:\b.txt');
SL.SaveToFile(RunFile);
Shellexecute(handle,nil,pchar(RunFile), nil, nil,SW_HIDE);
SL.Free;
end;
WinExec('command.com /c copy c:\a.txt c:\b.txt',SW_HIDE);
是正确的;
再试试
WinExec('command.com /c dir',SW_NORMAL);
既然WIN98与NT的命令解释器不一样,
win98: command.com 环境变量Comspec=c:\windows\command.com
NT与2000:cmd.exe 环境变量 Comspec=c:\nt\system32\cmd.exe就可根据环境变量知道了,通用程序:
char buf[256]
GetEnvironmentVariable("Comspec",buf,sizeof(buf));
String ComStr=String(buf)+" /c copy abc.txt 123.dat";
WinExec(ComStr.c_str(),SW_NORMAL);