Home > Back-end > Delphi run an external program and wait for the external program runs out, and not the end
Delphi run an external program and wait for the external program runs out, and not the end
Time:10-06
Run an external program and wait for the end of the external program to return the result of function in the following The function WinExecAndWait32 (FileName: string; Visibility: Boolean) : integer; Var ZAppName: an array of char [0.. 512];//store application name StartupInfo: TStartupInfo; ProcessInfo: TProcessInformation; ExitCode: Dword; AVisibility: integer; The begin StrPCopy (zAppName, FileName); FillChar (StartupInfo, Sizeof (StartupInfo), # 0); //to StartupInfo structure assignment StartupInfo. Cb:=Sizeof (StartupInfo); StartupInfo. DwFlags:=STARTF_USESHOWWINDOW; If the Visibility then AVisibility:=1 The else AVisibility:=0;
StartupInfo. WShowWindow:=aVisibility; //call the CreateProcess creation process, the implementation of the specified executable file If not CreateProcess (nil, zAppName, nil nil, false , CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS , nil nil, StartupInfo ProcessInfo) then Result:=1 The else The begin //wait for the executable file from WaitForSingleObject (ProcessInfo hProcess, INFINITE); //get the process termination status code GetExitCodeProcess (ProcessInfo hProcess, exitCode); Result:=exitCode; end; end;
How to change into, I need a lot of people say is modified to WaitForInputIdle But I really don't understand
CodePudding user response:
Run an external program and wait for the external program runs out And Run an external program and wait for the external program run over What's the difference?
CodePudding user response:
I posted above function is:
After the execution of the external programs must be closed to continue to perform down
But I want is that the effect of performance of the external program after fully open (main form is created) began to continue to perform down, the external program is not closed,
CodePudding user response:
Fog! LZ
CodePudding user response:
That use the inter-process communication, otherwise it is impossible to know what are you called program outside the main window is created,