title: Screenshot comes out black
body: <p>I'm trying to make a screen capture manager &amp; recorder, both screenshot &amp; video, although the latter is not important for this question.</p>
  
  <p>The user can select a process he/she wants to be captured and set a hotkey. </p>
  
  <p>The screenshots work fine for the regular desktop and some games. However, when trying to capture a screenshot from some games (e.g Splinter Cell Blacklist), if these games are full-screen, and depending on Windows 7 Aero, the contents are black, or the desktop is showing with a small bar at the top left of the screen.</p>
  
  <p>Here's my initial code:</p>
  
  <pre><code>public static Bitmap GetScreen()
  {
      Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  
      using (Graphics g = Graphics.FromImage(bmpScreenCapture))
      {
          g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
                           Screen.PrimaryScreen.Bounds.Y,
                           0, 0,
                           bmpScreenCapture.Size,
                           CopyPixelOperation.SourceCopy);
      }
  
     return bmpScreenCapture;
  }
  </code></pre>
  
  <p>During my search I found a code project article:</p>
  
  <p><a href="http://www.codeproject.com/Articles/274461/Very-fast-screen-capture-using-DirectX-in-Csharp" rel="nofollow">http://www.codeproject.com/Articles/274461/Very-fast-screen-capture-using-DirectX-in-Csharp</a> </p>
  
  <p>And slightly modified the code</p>
  
  <pre><code>public Surface CaptureScreen()
  {
      Surface s = Surface.CreateOffscreenPlain(d, rc.Width, rc.Height, Format.A8R8G8B8, Pool.Scratch);
      d.GetFrontBufferData(0, s);
  
      Surface.ToFile(s, @"C:\test\img.jpg", ImageFileFormat.Jpg);
      return s;
  }
  </code></pre>
  
  <p>However, also that image comes out black.</p>
  
  <p>Does anyone have any suggestions as to how this is done?</p>