SetWindowPos is used as the Windows API method. You can declare it like this:
[DllImport("user32.dll")]
private extern static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
and read about it here:
http://msdn.microsoft.com/en-us/library/ms633545.aspx
Added
Process.MainWindowHandle is the hWnd parameter that you will use. hWndInsertAfter will probably be your own form handle (Form.Handle). You can use a screen type to access desktop information:
http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx
Thomas comment added
Before calling SetWindowPos, make sure you WaitForInputIdle.
Process process = Process.Start(...);
if (process.WaitForInputIdle(15000))
SetWindowPos(process.MainWindowHandle, this.Handle, ...);
The declaration for SetWindowPos above works for both 32-bit and 64-bit Windows.
source
share