Free mag vol1 | Page 684

CHAPTER 17  PROCESSES, APPDOMAINS, AND OBJECT CONTEXTS Id This property gets the PID for the associated process. MachineName This property gets the name of the computer the associated process is running on. MainWindowTitle MainWindowTitle gets the caption of the main window of the process (if the process does not have a main window, you receive an empty string). Modules This property provides access to the strongly typed ProcessModuleCollection type, which represents the set of modules (*.dll or *.exe) loaded within the current process. ProcessName This property gets the name of the process (which, as you would assume, is the name of the application itself). Responding This property gets a value indicating whether the user interface of the process is responding to user input (or is currently “hung”). StartTime This property gets the time that the associated process was started (via a DateTime type). Threads This property gets the set of threads that are running in the associated process (represented via a collection of ProcessThread objects). In addition to the properties just examined, System.Diagnostics.Process also defines a few useful methods (see Table 17-3). Table 17-3. Select Methods of the Process Type Method Meaning in Life CloseMainWindow() This method closes a process that has a user interface by sending a close message to its main window. GetCurrentProcess() This static method returns a new Process object that represents the currently active process. GetProcesses() This static method returns an array of new Process objects running on a given machine. Kill() This method immediately stops the associated process. Start() This method starts a process. 627