我正在尝试启动具有提升状态的外部应用程序,并等到它退出后再继续:
var FProcess: THandle; ExecInfo: TShellExecuteInfo; begin FillChar(ExecInfo,SizeOf(ExecInfo),0); with ExecInfo do begin cbSize := SizeOf(ExecInfo); fMask := 0; Wnd := AWindow; lpVerb := 'runas'; lpFile := PChar(APath); lpParameters := PChar(AParams); lpDirectory := PChar(AWorkDir); nShow := SW_NORMAL; end; Result := ShellExecuteEx(@ExecInfo); if Wait then begin while WaitForSingleObject(ExecInfo.hProcess,INFINITE) <> WAIT_TIMEOUT do Application.ProcessMessages; end;
这个推出,但它只是在等待.调用程序永远不会继续调用WaitForSingleObject,即使在被调用的程序退出之后也是如此.
我尝试过WAIT_OBJECT_0而不是WAIT_TIMEOUT,但我遇到了同样的问题.我在这做错了什么?