Here is a simple d3d screen capture, you may need d3d9.h from your d3d install in your resources folder:
void TakeScreenShot(char* file_name)
{
LPDIRECT3D8 pD3D = NULL;
LPDIRECT3DDEVICE8 device = NULL;
pD3D = Direct3DCreate8( D3D_SDK_VERSION );
int nMode = 0;
D3DDISPLAYMODE d3ddm;
bool bDesiredAdaptorModeFound = false;
int nMaxAdaptorModes = pD3D->GetAdapterModeCount( 0 ); for( nMode = 0; nMode < nMaxAdaptorModes; ++nMode ) {
pD3D->EnumAdapterModes( D3DADAPTER_DEFAULT, nMode, &d3ddm );
if( d3ddm.Width != 640 || d3ddm.Height != 480 )
continue;
if( d3ddm.Format != D3DFMT_X8R8G8B8 )
continue;
if( d3ddm.RefreshRate != 75 )
continue;
bDesiredAdaptorModeFound = true;
break;
}
pD3D->CheckDeviceType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, FALSE );
pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16 );
D3DCAPS8 d3dCaps;
pD3D->GetDeviceCaps( D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL, &d3dCaps );
DWORD dwBehaviorFlags = 0;
if( d3dCaps.VertexProcessingCaps != 0 )
dwBehaviorFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
else
dwBehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
D3DPRESENT_PARAMETERS d3dpp;
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferWidth = 1600;
d3dpp.BackBufferHeight = 1200;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetDesktopWindow(), dwBehaviorFlags, &d3dpp, &device ); int screenx = GetSystemMetrics(SM_CXSCREEN);
int screeny = GetSystemMetrics(SM_CYSCREEN);
LPDIRECT3DSURFACE8 frontbuf = 0;
device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &frontbuf);
device->CreateImageSurface(screenx, screeny, D3DFMT_A8R8G8B8, &frontbuf);
HRESULT hr = device->GetFrontBuffer(frontbuf);
D3DXSaveSurfaceToFile(file_name, D3DXIFF_BMP, frontbuf, NULL, NULL);
frontbuf->Release();
device->Release();
pD3D->Release();
}