就等返回值嘛~~看帮助阿 Return ValuesIf 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. ERROR_PATH_NOT_FOUND The specified path was not found.
Return ValuesIf 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.
ERROR_PATH_NOT_FOUND The specified path was not found.
vStartUpInfo.dwFlags:=STARTF_USESHOWWINDOW;
vStartUpInfo.wShowWindow:=SW_SHOW; //SW_HIDE,程序执行时的显示模式
if CreateProcess(nil, PChar(ChangeFileExt(TextFilePath, '.bat')), nil, nil,False, IDLE_PRIORITY_CLASS,
nil, nil, vStartUpInfo,vProcessInfo) then //创建执行该批处理文件的进程,并得到进程信息
begin //通过进程句柄等待该进程执行完毕 第二个参数表示等待时间
WaitForSingleObject(vProcessInfo.hProcess, INFINITE);
CloseHandle(vProcessInfo.hThread); //关闭线程
CloseHandle(vProcessInfo.hProcess); //关闭进程
end;
//CreateProcess()函数中,第二个参数为要执行的DOS批处理命令.....其实通过调用
ShellExecute(Handle, nil,PChar(ChangeFileExt(TextFilePath,'.bat')), nil, nil, SW_SHOW); 这个函数也可以实现.只要将最后一个参数设为 sw_hide 即隐藏DOS运行窗口..不过第一个可以完全达到你的要求,等到这个DOS命令执行完毕后再继续执行程序....