该函数一直等到你运行的程序结束
function WinExecAndWait32(FileName:string;visibility:Integer):integer;
var
zAppName:array[0..512] of char;
zCurDir:array[0..255] of char;
workDir:string;
startUpInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
i
Word;
begin
StrPCopy(zAppName,FileName);
// GetDir(0,WorkDir);
// showmessage(workdir);
// StrPCopy(zCurDir,WorkDir);
FillChar(StartupInfo,sizeof(StartUpInfo),#0);
StartupInfo.cb:=sizeOf(StartUpInfo);
StartUpInfo.dwFlags:=STARTF_USESHOWWINDOW;
StartUpInfo.wShowWindow:=Visibility;
// winExec(zAppName,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,i);
Result:=i;
end;
end;