xtd 0.2.0
Loading...
Searching...
No Matches

◆ start_info() [1/3]

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.

Returns
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.
Examples
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.
#include <xtd/diagnostics/process>
#include <xtd/block_scope>
#include <xtd/console>
using namespace xtd;
using namespace xtd::diagnostics;
auto main() -> int {
try {
block_scope_(auto my_process = process {}) {
my_process.start_info().use_shell_execute(false);
// You can start any process other guidgen.
my_process.start_info().file_name("guidgen");
my_process.start_info().create_no_window(true);
my_process.start();
// This code assumes the process you are starting will terminate itself.
// Given that it is started without a window so you cannot terminate it
// on the desktop, it must terminate itself or you can do it programmatically
// from this application using the kill method.
}
} catch (const std::exception& e) {
}
}
// This code can produce the following output :
//
// 1549cf47-b1c9-4333-96e5-4eabffbd9fbd
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Provides access to local and remote processes and enables you to start and stop local system processe...
Definition process.h:49
#define block_scope_(...)
The specified expression is cleared automatically when the scope is ended.
Definition block_scope.h:25
@ e
The E key.
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.h:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Remarks
xtd::diagnostics::process_start_info represents the set of parameters to use to start a process. When xtd::diagnostics::process::start is called, the xtd::diagnostics::process::start_info is used to specify the process to start. The only necessary xtd::diagnostics::process::start_info member to set is the xtd::diagnostics::process_start_info::file_name property. Starting a process by specifying the xtd::diagnostics::process_start_info::file_name property is similar to typing the information in the Run dialog box of the Windows Start menu. Therefore, the xtd::diagnostics::process_start_info::file_name property does not need to represent an executable file. It can be of any file type for which the extension has been associated with an application installed on the system. For example the xtd::diagnostics::process_start_info::file_name can have a .txt extension if you have associated text files with an editor, such as Notepad, or it can have a .doc if you have associated .doc files with a word processing tool, such as Microsoft Word. Similarly, in the same way that the Run dialog box can accept an executable file name with or without the .exe extension, the .exe extension is optional in the xtd::diagnostics::process_start_info::file_name member. For example, you can set the xtd::diagnostics::process_start_info::file_name property to either "Notepad.exe" or "Notepad".
If the file name involves a nonexecutable file, such as a .doc file, you can include a verb specifying what action to take on the file. For example, you could set the Verb to "Print" for a file ending in the .doc extension. The file name specified in the xtd::diagnostics::process::start_info::file_name property does not need to have an extension if you manually enter a value for the Verb property. However, if you use the Verbs property to determine what verbs are available, you must include the extension.
You can change the parameters specified in the xtd::diagnostics::process::start_info property up to the time that you call the xtd::diagnostics::process::start method on the process. After you start the process, changing the xtd::diagnostics::process::start_info values does not affect or restart the associated process. If you call the xtd::diagnostics::process::start(xtd::diagnostics::process_start_info) method with the xtd::diagnostics::process_start_info. xtd::diagnostics::process::start_info::user_name and xtd::diagnostics::process::start_info::password properties set, the unmanaged CreateProcessWithLogonW function is called, which starts the process in a new window even if the xtd::diagnostics::process::start_info::create_no_window property value is true or the xtd::diagnostics::process::start_info::window_style property value is xtd::diagnostics::process_window_style::hidden.
You should only access the xtd::diagnostics::process::start_info property on a xtd::diagnostics::process object returned by the Start method. For example, you should not access the xtd::diagnostics::process::start_info property on a xtd::diagnostics::process object returned by xtd::diagnostics::process::get_processes.