title: How to hide / unhide a process in C#?
body: <p>I am attempting to start an external process in a Visual C# 2010 - Windows Forms application.  The goal is to start the process as a hidden window, and unhide the window at a later time.</p>
  
  <p>I've updated my progress:</p>
  
  <pre><code>//Initialization
  [DllImport("user32.dll")]
  private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
  [DllImport("user32.dll")]
  private static extern bool EnableWindow(IntPtr hwnd, bool enable);
  [DllImport("user32.dll")]
  private static extern bool MoveWindow(IntPtr handle, int x, int y, int width, 
  int height, bool redraw);
  
  SW_SHOW = 5;
  </code></pre>
  
  <p>The following was placed in my main function:</p>
  
  <pre><code>ProcessStartInfo info = new ProcessStartInfo("process.exe");
  info.WindowStyle = ProcessWindowStyle.Hidden;
  Process p = Process.Start(info);
  
  p.WaitForInputIdle();
  IntPtr HWND = p.MainWindowHandle;
  
  System.Threading.Thread.Sleep(1000);    
  
  ShowWindow(HWND, SW_SHOW);
  EnableWindow(HWND, true);
  MoveWindow(HWND, 0, 0, 640, 480, true);
  </code></pre>
  
  <p>However, because the window was started as "hidden," <code>p.MainWindowHandle = 0</code>.  I am not able to successfully show the window.  I have also tried <code>HWND = p.Handle</code> with no success.</p>
  
  <p>Is there a way to provide a new handle to my window?  This could potentially fix my problem.</p>
  
  <p>References:</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx" rel="noreferrer">MSDN ShowWindow</a></p>
  
  <p><a href="http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/12d1840d-e894-4097-ae41-46e69bb5b5c0/" rel="noreferrer">MSDN Forums</a></p>
  
  <p><a href="http://en.csharp-online.net/Attributes" rel="noreferrer">How to Import .dll</a></p>