Posts

Showing posts from December, 2009

Controlling External .Net Processes

I have a project where I wanted to be able to provide my users with a button that would open an external application. The idea is that the interaction would be seamless so that from the users perspective, the external application would seem to be apart of my application. To pull this off, I needed to be able to bring the main window(s) of the external application to the front if I had already launched it but the user clicked the button again. For this implementation, I tried to use the following .Net implementation: _process.WaitForInputIdle(1000); IntPtr mainWindowsHandle = _process.MainWindowHandle; //show the process's window if applicable else inform the user if (!mainWindowsHandle.Equals(IntPtr.Zero)) { //show the process's main window ShowWindow(mainWindowsHandle, 1); SetForegroundWindow(mainWindowsHandle); } Here we get the handle to the main window of the process and we call the win32 ShowWindow and SetForegroundWindow methods to the fro