C++ Stack Overflow

void dump_buffer()
   IDirect3DSurface9* pRenderTarget=NULL;
   IDirect3DSurface9* pDestTarget=NULL;
     const char file[] = "Pickture.bmp";
   // sanity checks.
   if (Device == NULL)

   // get the render target surface.
   HRESULT hr = Device->GetRenderTarget(0, &pRenderTarget);
   // get the current adapter display mode.
   //hr = pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddisplaymode);

   // create a destination surface.
   hr = Device->CreateOffscreenPlainSurface(DisplayMde.Width,
   //copy the render target to the destination surface.
   hr = Device->GetRenderTargetData(pRenderTarget, pDestTarget);
   //save its contents to a bitmap file.
   hr = D3DXSaveSurfaceToFile(file,

   // clean up.

C# with Microsoft Expression Encoder 4 with Service Pack 2 (SP2)

using System;
using System.Drawing;
using Microsoft.Expression.Encoder.ScreenCapture;

// Added references to:
// Microsoft.Expression.Encoder
// Microsoft.Expression.Encoder.Types
// Microsoft.Expression.Encoder.Utilities
// WindowsBase
// System.Drawing (for Rectangle)

namespace scrcap
    class Program
        static void Main(string[] args)
            ScreenCaptureJob job = new ScreenCaptureJob();

            // You can capture a window by setting its coordinates here
            job.CaptureRectangle = new Rectangle(100, 100, 200, 200);

            // Include the mouse pointer in the captured video
            job.CaptureMouseCursor = true;

            // Output file; you can transcode the xesc file to something else later.
            // Note that this silently does nothing if the file already exists.
            job.OutputScreenCaptureFileName = @"C:\Users\arx\scrcap\capture.xesc";

            // Do some capture
            // Wait for a keypress
            // And stop

Another C++ Example

C# by using Screen Video Capturing SDK

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Diagnostics;

using BytescoutScreenCapturingLib; //import bytescout screencapturing activex object 

namespace SimpleCaptureCSharp
   class Program
       static void Main(string[] args)
           CapturerClass capturer = new CapturerClass(); 
           // create new screen capturer objec
           CapturerClass capturer = new CapturerClass(); 
           capturer.CapturingType = CaptureAreaType.catScreen; 
           // set capturing area type to catScreen to capture whole screen 
           capturer.OutputFileName = "EntireScreenCaptured.wmv"; 
           // set output video filename to .WMV or .AVI file 
           // set output video width and height 
           capturer.OutputWidth = 640; 
           capturer.OutputHeight = 480; 
// uncomment to set Bytescout Lossless Video format output video compression method
// do not forget to set file to .avi format if you use Video Codec Name 
// capturer.CurrentVideoCodecName = "Bytescout Lossless"; 
           capturer.Run(); // run screen video capturing 
           Thread.Sleep(15000); // wait for 15 seconds 
           capturer.Stop(); // stop video capturing 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s