NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Process.MainWindowHandle

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;

Property Value

The system-generated window handle of the main window of the associated process.

Exceptions

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.

Remarks

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.

See Also

Process Class | Process Members | System.Diagnostics Namespace | MainWindowTitle | MainModule