xtd - Reference Guide
0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
|
#include <process.h>
Provides access to local and remote processes and enables you to start and stop local system processes.
The following example populates a StartInfo with the file to execute, the action performed on it and whether it should displays a user interface. For additional examples, refer to the reference pages for properties of the ProcessStartInfo class.
Inherits xtd::object.
Classes | |
class | error_data_received_event |
Represents a process error data received event. More... | |
class | exit_event |
Represents a process exit event. More... | |
class | output_data_received_event |
Represents a process output data received event. More... | |
Public Types | |
using | time_point = std::chrono::system_clock::time_point |
Represents a point in time. | |
Public Attributes | |
error_data_received_event | error_data_received |
Occurs when an application writes to its redirected xtd::diagnostics::process::standard_error stream. | |
exit_event | exited |
Occurs when a process exits. | |
output_data_received_event | output_data_received |
Occurs each time an application writes a line to its redirected xtd::diagnostics::process::standard_output stream. | |
Public Member Functions | |
process () | |
Initializes a new instance of the xtd::diagnostics::process class. | |
int32_t | base_priority () const |
Gets the base priority xof the associated process. | |
void | close () |
Frees all the resources that are associated with this component. | |
bool | enable_raising_events () const |
Gets whether the xtd::diagnostics::process::exited event should be raised when the process terminates. | |
process & | enable_raising_events (bool value) |
Sets whether the xtd::diagnostics::process::exited event should be raised when the process terminates. | |
int32_t | exit_code () const |
Gets the value that the associated process specified when it terminated. | |
time_point | exit_time () const |
Gets the time that the associated process exited. | |
intptr_t | handle () const |
Gets the native handle of the associated process. | |
bool | has_exited () const |
Gets a value indicating whether the associated process has been terminated. | |
int32_t | id () const |
Gets the unique identifier for the associated process. | |
void | kill () |
Immediately stops the associated process. | |
ustring | machine_name () const |
Gets the name of the computer the associated process is running on. | |
xtd::diagnostics::process_priority_class | priority_class () const |
Gets the overall priority category for the associated process. | |
process & | priority_class (xtd::diagnostics::process_priority_class value) |
Sets the overall priority category for the associated process. | |
ustring | process_name () const |
Gets the name of the process. | |
std::istream & | standard_error () |
Gets a stream used to read the error output of the application. | |
std::ostream & | standard_input () |
Gets a stream used to write the input of the application. | |
std::istream & | standard_output () |
Gets a stream used to read the textual output of the application. | |
bool | start () |
Starts (or reuses) the process resource that is specified by the xtd::diagnostics::process::start_info property of this Process component and associates it with the component. | |
xtd::diagnostics::process_start_info & | start_info () |
Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process. | |
const xtd::diagnostics::process_start_info & | start_info () const |
Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process. | |
process & | start_info (const xtd::diagnostics::process_start_info &value) |
SGets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process. | |
time_point | start_time () const |
Gets the time that the associated process was started. | |
process & | wait_for_exit () |
Instructs the xtd::diagnostics::process component to wait indefinitely for the associated process to exit. | |
process & | wait_for_exit (int32_t milliseconds) |
Instructs the Process component to wait the specified number of milliseconds for the associated process to exit. | |
Public Member Functions inherited from xtd::object | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual size_t | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
template<typename object_t > | |
std::unique_ptr< object_t > | memberwise_clone () const |
Gets the type of the current instance. | |
virtual xtd::ustring | to_string () const noexcept |
Returns a std::string that represents the current object. | |
Static Public Member Functions | |
static process | start (const ustring &file_name) |
Starts a process resource by specifying the name of a document or application file and associates the resource with a new Process component. | |
static process | start (const ustring &file_name, const ustring &arguments) |
Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new xtd::diagnostics::process component. | |
static process | start (const xtd::diagnostics::process_start_info &start_info) |
Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new xtd::diagnostics::process component. | |
Static Public Member Functions inherited from xtd::object | |
static bool | equals (const object &object_a, const object &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
Protected Member Functions | |
virtual void | on_exited () |
Raises the xtd::diagnostics::process::exited event. | |
using xtd::diagnostics::process::time_point = std::chrono::system_clock::time_point |
Represents a point in time.
xtd::diagnostics::process::process | ( | ) |
Initializes a new instance of the xtd::diagnostics::process class.
int32_t xtd::diagnostics::process::base_priority | ( | ) | const |
Gets the base priority xof the associated process.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
Windows base_priority | macOS base_priority | linux base_priority | priority_class |
---|---|---|---|
4 | PRIO_MIN (-20) | PRIO_MIN (-20) | xtd::diagnostics::process_priority_class::idle |
6 | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | xtd::diagnostics::process_priority_class::below_normal |
8 | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | xtd::diagnostics::process_priority_class::normal |
10 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | xtd::diagnostics::process_priority_class::above_normal |
13 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | xtd::diagnostics::process_priority_class::high |
24 | PRIO_MAX (20) | PRIO_MAX (20) | xtd::diagnostics::process_priority_class::real_time |
void xtd::diagnostics::process::close | ( | ) |
Frees all the resources that are associated with this component.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
bool xtd::diagnostics::process::enable_raising_events | ( | ) | const |
Gets whether the xtd::diagnostics::process::exited event should be raised when the process terminates.
process & xtd::diagnostics::process::enable_raising_events | ( | bool | value | ) |
Sets whether the xtd::diagnostics::process::exited event should be raised when the process terminates.
value | true if the xtd::diagnostics::process::exited event should be raised when the associated process is terminated (through either an exit or a call to xtd::diagnostics::process::kill()); otherwise, false. The default is false. Note that the xtd::diagnostics::process::exited event is raised even if the value of xtd::diagnostics::process::enable_raising_events is false when the process exits during or before the user performs a xtd::diagnostics::process::has_exited check. |
int32_t xtd::diagnostics::process::exit_code | ( | ) | const |
Gets the value that the associated process specified when it terminated.
xtd::invalid_operation_exception | The process has not exited. -or- The process xtd::diagnostics::process::handle is not valid. |
xtd::not_supported_exception | You are trying to access the xtd::diagnostics::process::exit_code property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer. |
time_point xtd::diagnostics::process::exit_time | ( | ) | const |
Gets the time that the associated process exited.
xtd::not_supported_exception | You are trying to access the xtd::diagnostics::process::exit_time property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer. |
intptr_t xtd::diagnostics::process::handle | ( | ) | const |
Gets the native handle of the associated process.
xtd::invalid_operation_exception | The process has not been started or has exited. The xtd::diagnostics::process::handle property cannot be read because there is no process associated with this xtd::diagnostics::process instance. -or- The xtd::diagnostics::process instance has been attached to a running process but you do not have the necessary permissions to get a handle with full access rights. |
xtd::not_supported_exception | You are trying to access the xtd::diagnostics::process::handle property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer. |
bool xtd::diagnostics::process::has_exited | ( | ) | const |
Gets a value indicating whether the associated process has been terminated.
xtd::invalid_operation_exception | There is no process associated with the object. |
xtd::not_supported_exception | You are trying to access the xtd::diagnostics::process::has_exited property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer. |
int32_t xtd::diagnostics::process::id | ( | ) | const |
Gets the unique identifier for the associated process.
xtd::invalid_operation_exception | The process's Id property has not been set. |
void xtd::diagnostics::process::kill | ( | ) |
Immediately stops the associated process.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
ustring xtd::diagnostics::process::machine_name | ( | ) | const |
Gets the name of the computer the associated process is running on.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
|
protectedvirtual |
Raises the xtd::diagnostics::process::exited event.
xtd::diagnostics::process_priority_class xtd::diagnostics::process::priority_class | ( | ) | const |
Gets the overall priority category for the associated process.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
Windows base_priority | macOS base_priority | linux base_priority | priority_class |
---|---|---|---|
4 | PRIO_MIN (-20) | PRIO_MIN (-20) | xtd::diagnostics::process_priority_class::idle |
6 | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | xtd::diagnostics::process_priority_class::below_normal |
8 | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | xtd::diagnostics::process_priority_class::normal |
10 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | xtd::diagnostics::process_priority_class::above_normal |
13 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | xtd::diagnostics::process_priority_class::high |
24 | PRIO_MAX (20) | PRIO_MAX (20) | xtd::diagnostics::process_priority_class::real_time |
process & xtd::diagnostics::process::priority_class | ( | xtd::diagnostics::process_priority_class | value | ) |
Sets the overall priority category for the associated process.
value | The priority category for the associated process, from which the xtd::diagnostics::process::base_priority of the process is calculated. |
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
Windows base_priority | macOS base_priority | linux base_priority | priority_class |
---|---|---|---|
4 | PRIO_MIN (-20) | PRIO_MIN (-20) | xtd::diagnostics::process_priority_class::idle |
6 | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | xtd::diagnostics::process_priority_class::below_normal |
8 | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | xtd::diagnostics::process_priority_class::normal |
10 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | xtd::diagnostics::process_priority_class::above_normal |
13 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | xtd::diagnostics::process_priority_class::high |
24 | PRIO_MAX (20) | PRIO_MAX (20) | xtd::diagnostics::process_priority_class::real_time |
ustring xtd::diagnostics::process::process_name | ( | ) | const |
Gets the name of the process.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
std::istream & xtd::diagnostics::process::standard_error | ( | ) |
Gets a stream used to read the error output of the application.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
std::ostream & xtd::diagnostics::process::standard_input | ( | ) |
Gets a stream used to write the input of the application.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::processes object. |
std::istream & xtd::diagnostics::process::standard_output | ( | ) |
Gets a stream used to read the textual output of the application.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
bool xtd::diagnostics::process::start | ( | ) |
Starts (or reuses) the process resource that is specified by the xtd::diagnostics::process::start_info property of this Process component and associates it with the component.
xtd::invalid_operation_exception | No file name was specified in the xtd::diagnostics::process component's xtd::diagnostics::process::start_info. |
Starts a process resource by specifying the name of a document or application file and associates the resource with a new Process component.
file_name | The name of a document or application file to run in the process. |
xtd::invalid_operation_exception | No file name was specified in the file_name parameter's xtd::diagnostics::process_start_info::file_name property. |
|
static |
Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new xtd::diagnostics::process component.
file_name | The name of a document or application file to run in the process. |
arguments | Command-line arguments to pass when starting the process. |
xtd::invalid_operation_exception | No file name was specified in the file_name parameter's xtd::diagnostics::process_start_info::file_name property. |
|
static |
Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new xtd::diagnostics::process component.
The | xtd::diagnostics::process_start_ifo that contains the information that is used to start the process, including the file name and any command-line arguments. |
xtd::invalid_operation_exception | No file name was specified in the startInfo parameter's xtd::diagnostics::process_start_info::file_name property. |
xtd::diagnostics::process_start_info & xtd::diagnostics::process::start_info | ( | ) |
Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process.
const xtd::diagnostics::process_start_info & xtd::diagnostics::process::start_info | ( | ) | const |
Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process.
process & xtd::diagnostics::process::start_info | ( | const xtd::diagnostics::process_start_info & | value | ) |
SGets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process.
value | The xtd::diagnostics::process_start_info that represents the data with which to start the process. These arguments include the name of the executable file or document used to start the process. |
time_point xtd::diagnostics::process::start_time | ( | ) | const |
Gets the time that the associated process was started.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
process & xtd::diagnostics::process::wait_for_exit | ( | ) |
Instructs the xtd::diagnostics::process component to wait indefinitely for the associated process to exit.
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
process & xtd::diagnostics::process::wait_for_exit | ( | int32_t | milliseconds | ) |
Instructs the Process component to wait the specified number of milliseconds for the associated process to exit.
milliseconds | The amount of time, in milliseconds, to wait for the associated process to exit. A value of 0 specifies an immediate return, and a value of -1 specifies an infinite wait.The amount of time, in milliseconds, to wait for the associated process to exit. A value of 0 specifies an immediate return, and a value of -1 specifies an infinite wait. |
xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
error_data_received_event xtd::diagnostics::process::error_data_received |
Occurs when an application writes to its redirected xtd::diagnostics::process::standard_error stream.
exit_event xtd::diagnostics::process::exited |
Occurs when a process exits.
output_data_received_event xtd::diagnostics::process::output_data_received |
Occurs each time an application writes a line to its redirected xtd::diagnostics::process::standard_output stream.