Replace my CSafeString instance with a standard C++ string method and this will do what you're after.
Code:
HRESULT CGraphicsManager::Screenshot()
{
USES_CONVERSION;
HRESULT hr;
LPDIRECT3DSURFACE9 pTex;
// create the image surface to store the front buffer image
// note that call to GetFrontBuffer will always convert format to A8R8G8B8
if (FAILED(hr = v_p3DDevice->CreateOffscreenPlainSurface(800, 600, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pTex, NULL)))
return hr;
// read the front buffer into the image surface
if (FAILED(hr = v_p3DDevice->GetFrontBufferData(0, pTex)))
{
pTex->Release();
return hr;
}
// write the entire surface to the requested file
CSafeString file("ScreenShot");
file += ntoa(v_ShotCountS);
file += ".BMP";
hr = D3DXSaveSurfaceToFile( A2W( file() ) , D3DXIFF_BMP, pTex, NULL, NULL);
// release the image surface
pTex->Release();
v_ShotCountS ++;
return hr;
}