我倒是觉得楼主的问题可以解决:
//对于 WinExec
If the function succeeds, the return value is greater than 31.
If the function fails, the return value is one of the following error values:
Value Meaning
0 The system is out of memory or resources.
ERROR_BAD_FORMAT The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).
ERROR_FILE_NOT_FOUND The specified file was not found.
procedure TForm1.Button1Click(Sender: TObject);
var ReTurn:Integer;
begin
ReTurn:=winexec(pchar('command.com /C '+'net view '+' >'+'c:\xinxi.txt'),sw_hide);
if ReTurn>31 then
begin
if not fileexists('c:\xinxi.txt') then
sleep(100)
else
memo1.Lines.LoadFromFile('c:\xinxi.txt');
end;
end;//既然你都能把结果给得到了,还你能判断妈 /?
function TExecForm.Exec(FileName: string; Visibility: integer): integer;
var
zappname:array [0..512] of char;
zcurdir:array [0..255] of char;
workdir:string;
startupinfo:tstartupinfo;
processinfo:tprocessinformation;
exitcode:cardinal;
begin
strpcopy(zappname,filename);
getdir(0,workdir);
strpcopy(zcurdir,workdir);
fillchar(startupinfo,sizeof(startupinfo),#0);
startupinfo.cb:=sizeof(startupinfo);
startupinfo.wShowWindow:=visibility;
if not createprocess(nil,zappname,nil,nil,false,create_new_console or Normal_priority_class,
nil,nil,startupinfo,processinfo) then result:=-1
else begin
waitforsingleobject(processinfo.hProcess,infinite);
getexitcodeprocess(processinfo.hProcess,exitcode);
result:=exitcode;
end;
end;
procedure TExecForm.ExecuteClick(Sender: TObject);
var h:thandle;
begin
exec(exename.Text,0);
showmessage('Ruturn');
end;