Start(RawInfo: IShellExecuteInfo);
RawInfo. Running process information.
The Start method starts the process.
Executing the example requires the "start" console application in the folder D:\Work\Project\ for Windows OS, and in the folder /usr/local/bin for Linux OS. The application can take one integer parameter value for input.
Add a link to the Host system assembly.
Sub UserProc;
Var
Info: IShellExecuteInfo;
Proc: IShellProcess;
Begin
// Application start parameters
Info := New ShellExecuteInfo.Create;
Info.Directory := "/usr/local/bin";
Info.File := "start";
Info.Parameters := "1";
Info.WaitToTerminate := True;
Info.WaitTimeout := 30000;
// Start application
Proc := New ShellProcess.Create;
Proc.Start(Info);
// If process is still being executed, finish it
While Not Proc.HasExited Do
Proc.Kill;
End While;
// Application execution result
If Proc.HasExited Then
Debug.WriteLine("Exit Code:" + Proc.ExitCode.ToString);
Debug.WriteLine("Output: " + Proc.Output);
Debug.WriteLine(Proc.Error <> "" ? "Error: " + Proc.Error : "No error.");
End If;
End Sub UserProc;
Sub UserProc;
Var
Info: IShellExecuteInfo;
Proc: IShellProcess;
Begin
// Application start parameters
Info := New ShellExecuteInfo.Create;
Info.Directory := "D:\Work\Project\";
Info.File := "start.exe";
Info.Parameters := "1";
Info.WaitToTerminate := True;
Info.WaitTimeout := 30000;
// Start application
Proc := New ShellProcess.Create;
Proc.Start(Info);
// If process is still being executed, finish it
While Not Proc.HasExited Do
Proc.Kill;
End While;
// Application execution result
If Proc.HasExited Then
Debug.WriteLine("Exit Code:" + Proc.ExitCode.ToString);
Debug.WriteLine("Output: " + Proc.Output);
Debug.WriteLine(Proc.Error <> "" ? "Error: " + Proc.Error : "No error.");
End If;
End Sub UserProc;
After executing the example the specified console application will be started. The parameter value will be sent to the application. The current application will await for 30 seconds for the running application to finish. If, after the time is out, the application is still being executed, it will be force stopped. Application execution results will be displayed in the development environment console.
See also: