title: Stop a process from showing a window from C#
body: <p>I'm trying to automate an application that creates a GUI window on startup that has no user interaction, but I can't figure out how to hide the actual window.</p>
  
  <p>I've tried using ProcessStartInfo thus:</p>
  
  <pre><code>Process.Start(new ProcessStartInfo {
      UseShellExecute = false,
      CreateNoWindow = true,
      WindowStyle = ProcessWindowStyle.Hidden,
  
      // other properties here
  });
  </code></pre>
  
  <p>But the window still shows up.</p>
  
  <p>I've also tried spin-waiting for the window to exist, and then hiding it:</p>
  
  <pre><code>while (process.MainWindowHandle == IntPtr.Zero) {}
  ShowWindowAsync(process.MainWindowHandle, SW_HIDE);
  </code></pre>
  
  <p>This, unfortunately, makes the window flash for about 1/16th of a second or so, and I'd like to avoid it if at all possible.</p>
  
  <p>My current thoughts are along the line of creating a <a href="http://msdn.microsoft.com/en-us/library/ms644959%28v=vs.85%29.aspx" rel="nofollow">hook</a>, but am unsure of what hooks to grab, nor if it will even work.</p>
  
  <p>Any tips?</p>