class Windows::Process

A class encapsulating a native Windows process.

Global Functions

Process Create (const string)Starts a new process from a command line and returns the corresponding Process object.
Process Create (const string, const int)Starts a new process from a command line and returns the corresponding Process object.
Process Create (const string, const int, const table)Starts a new process from a command line and returns the corresponding Process object.
Process Create (const string, const table, const Console)Starts a new console process and returns the corresponding Process object.
DoEvents ()Performs window message processing for the calling application.
table GetEnvironment ()Returns a hash table containing a set of environment variables for the current process.
Sleep (const int)Puts the calling thread to sleep for the specified number of milliseconds.

Methods

Window FindWindow (const string)Searches for a window of the process that contains the specified title.
Terminate ()Kills the process without allowing it to save any data.
int Wait (const int)Causes the calling process to wait for this process for the specified number of milliseconds.
int WaitForExit ()Causes the calling process to wait indefinitely until this process has exited.

Properties

string CommandLine ()Returns the command line that was used to create this process.
int ExitCode ()Returns the exit code of this process.
Window MainWindow ()Returns the main window of the process.

Type Declaration

native class Windows::Process
{
    ["A class encapsulating a native Windows process."]
    function Process Create (const string cmd); ["Starts a new process from a command line and returns the corresponding Process object."]
    function Process Create (const string cmd, const int windowState); ["Starts a new process from a command line and returns the corresponding Process object. For available 'windowState' values, see Window::ShowWindow()."]
    function Process Create (const string cmd, const int windowState, const table environment); ["Starts a new process from a command line and returns the corresponding Process object. This method can pass a hash table containing a set of environment variables to the new process."]
    function Process Create (const string cmd, const table environment, const Windows::Console); ["Starts a new console process and returns the corresponding Process object. The new process will use the specified Console instance for message output."]
    function DoEvents (); ["Performs window message processing for the calling application. This method must be called from the application's main thread only."]
    function Sleep (const int millis); ["Puts the calling thread to sleep for the specified number of milliseconds."]
    function table GetEnvironment(); ["Returns a hash table containing a set of environment variables for the current process."]
    accessor string CommandLine (); ["Returns the command line that was used to create this process."]
    accessor int ExitCode (); ["Returns the exit code of this process. If the process is still running, returns ExitCode_StillActive."]
    method int Wait (const int millisec); ["Causes the calling process to wait for this process for the specified number of milliseconds. Returns Wait_Signaled if this process has exited during the wait, or Wait_TimeOut if the time has elapsed and this process is still running."]
    method int WaitForExit (); ["Causes the calling process to wait indefinitely until this process has exited."]
    accessor Window MainWindow (); ["Returns the main window of the process."]
    method Window FindWindow (const string title); ["Searches for a window of the process that contains the specified title. Returns the first window of the process with a matching title. The search is case sensitive. If no window is found, null is returned."]
    method Terminate (); ["Kills the process without allowing it to save any data. USE WITH CAUTION. If possible, call Close on the process's MainWindow instead of terminating the process."]
    const int ExitCode_NoError = 0;
    const int ExitCode_StillActive = 259;
    const int Wait_Abandoned = 128;
    const int Wait_Signaled = 0;
    const int Wait_TimeOut = 258;
    const int Wait_Failed = -1;
}

Reference

function Process Create (const string cmd)

Starts a new process from a command line and returns the corresponding Process object.


function Process Create (const string cmd, const int windowState)

Starts a new process from a command line and returns the corresponding Process object.

For available 'windowState' values, see Window::ShowWindow().


function Process Create (const string cmd, const int windowState, const table environment)

Starts a new process from a command line and returns the corresponding Process object.

This method can pass a hash table containing a set of environment variables to the new process.


function Process Create (const string cmd, const table environment, const Console)

Starts a new console process and returns the corresponding Process object.

The new process will use the specified Console instance for message output.


function DoEvents ()

Performs window message processing for the calling application.

This method must be called from the application's main thread only.


function table GetEnvironment ()

Returns a hash table containing a set of environment variables for the current process.


function Sleep (const int millis)

Puts the calling thread to sleep for the specified number of milliseconds.


method Window FindWindow (const string title)

Searches for a window of the process that contains the specified title.

Returns the first window of the process with a matching title. The search is case sensitive. If no window is found, null is returned.


method Terminate ()

Kills the process without allowing it to save any data.

USE WITH CAUTION. If possible, call Close on the process's MainWindow instead of terminating the process.


method int Wait (const int millisec)

Causes the calling process to wait for this process for the specified number of milliseconds.

Returns Wait_Signaled if this process has exited during the wait, or Wait_TimeOut if the time has elapsed and this process is still running.


method int WaitForExit ()

Causes the calling process to wait indefinitely until this process has exited.


accessor string CommandLine ()

Returns the command line that was used to create this process.


accessor int ExitCode ()

Returns the exit code of this process.

If the process is still running, returns ExitCode_StillActive.


accessor Window MainWindow ()

Returns the main window of the process.