Returns the window handle of the main window of the associated process.
[Visual Basic] Public ReadOnly Property MainWindowHandle As Integer [C#] public int MainWindowHandle {get;} [C++] public: __property int get_MainWindowHandle(); [JScript] public function get MainWindowHandle() : int;
The system-generated window handle of the main window of the associated process.
Exception Type | Condition |
---|---|
SystemException | The MainWindowHandle is not defined because the process has exited.
-or- You are attempting to retrieve the MainWindowHandle for a process running on a remote computer. |
You can only retrieve the MainWindowHandle for processes running on the local computer. The MainWindowHandle is a 32-bit value assigned that uniquely identifies the window that is responsible for the startup of the process.
A process only has a main window associated with it if the process has a graphical interface. If the associated process does not have a main window, the MainWindowHandle value is zero (0). If you have just started a process, and would like to use its main window handle, consider using the WaitForInputIdle method to allow the process to finish starting and ensure the main window handle has been created. Otherwise, an exception will be thrown.
Process Class | Process Members | System.Diagnostics Namespace | MainWindowTitle | MainModule