i changed the code as
LPDIRECT3DSURFACE9 pRenderTarget=NULL;
// get the render target surface.
m_pd3dDevice->GetRenderTarget(0, &pRenderTarget);
//save its contents to a bitmap file.
hr = D3DXSaveSurfaceToFile("c:\\file.jpg",
D3DXIFF_JPG,
pRenderTarget,
NULL,
NULL);
hr =...