我现在需要在程序中用CreateProcess运行另一个程序并且等待后者执行完毕,怎么
写CreateProcess的参数和知道后一个程序什么时候结束呢?
写CreateProcess的参数和知道后一个程序什么时候结束呢?
解决方案 »
- 请教删除记录的问题
- 升级到D2007后出现Operation not allowed on a unidirectional DataSet,怎么解决呀?
- 在做地图时遇到的一个问题
- 简单问题!
- 已知文件路径,怎么实现windows桌面那种效果(用大图标显示,并且能执行的)
- win2k中如何更改默认网关(用delphi编)?
- 大家帮帮忙,我的朋友做了软件,他现在很急,很可怜,很菜,很无助
- 在delphi6中,使用oracle 8.1.5的表,为什么其中的中文记录值显示为乱码?是不是和oracle的字符集有关系?
- 为什么我的query的active属性不能设为true????
- 为什么Winexec不能正确执行程序?
- 急死-关于读取数据库里的图片
- 菜鸟问题: 什么是内存映射?
2 你可以用一个event对象来探测,在父进程中waitforsingleobject
Function LaunchApp(pExePath,WorkDir:String;ShowWindow,WaitFlag:Boolean):Boolean;
var ExePath : array[0..512] of char;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
StrPCopy(exePath, pExePath);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
if ShowWindow then
StartupInfo.wShowWindow := 1
else
StartupInfo.wShowWindow := 0;
if not CreateProcess(nil,
ExePath,
nil,
nil,
false,
CREATE_NEW_CONSOLE or
NORMAL_PRIORITY_CLASS,
nil,
nil,
StartupInfo,
ProcessInfo) then begin
Result:=False;
Exit;
end else begin
if WaitFlag then
WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
Result:=True;
end;
end;
GetExitCodeProcess(ProcessInfo.hProcess,Result);