执行一个外部程序并等待它的完成,代码如下:
---------------------------------------------
Function WinExecExW(cmd,workdir
char;visiable:integer)
WORD;
var
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
FillChar(StartupInfo,SizeOf(StartupInfo),#0);
StartupInfo.cb:=SizeOf(StartupInfo);
StartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow:=visiable;
if not CreateProcess(nil,cmd,nil,nil,false,Create_new_console or Normal_priority_class,nil,nil,StartupInfo,ProcessInfo) then
result:=0
else
begin
waitforsingleobject(processinfo.hProcess,INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess,Result);
end;
------------------
可否达到你的要求?