When you click the Go... button of the application window, this creates the new process of the Internet Explorer (iexplore.exe) window and opens the URL specified to the process as its Arguments, once we call the process.Start() method.
When you click the BringToFront button, it retrieves the handle of the main window of the process and passes it as parameter to the SetForegroundWindow Win32 API method. The said API method brings the thread into the foreground and activates the window.
A process can set the foreground window only if one of the following conditions is satisfied:
- The process itself is a foreground process
- It was started by a foreground process
- The process is being debugged
- The foreground process is not a Modern Application or the Start screen
- No menus are active
The DllImport attribute indicates that the attributed method is exposed by an unmanaged dynamic-link library (DLL) as a static entry point. In our case, it's the User32.dll file.
When you...