char *bmp_buffer;
bmp_buffer = new[1024 * 768];
void CaptureScreen2()
{
int w = GetSystemMetrics(SM_CXSCREEN);
int h = GetSystemMetrics(SM_CYSCREEN);
HDC hDesktopDC = ::GetDC(NULL);
HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC, w, h);
SelectObject(hCaptureDC,hCaptureBitmap);
BitBlt(hCaptureDC,0,0,w,h, hDesktopDC,0,0,SRCCOPY);
BITMAP bitmap;
GetBitmapBits(hCaptureBitmap, sizeof (BITMAP), (LPSTR)&bitmap);
BITMAPINFOHEADER bih = {0};
bih.biBitCount = 32;
bih.biCompression = BI_RGB;
bih.biHeight = h;
bih.biPlanes = 1;
bih.biSize = sizeof(BITMAPINFOHEADER);
bih.biSizeImage = w * h * 4;
bih.biWidth = w;
GetDIBits(hDesktopDC, hCaptureBitmap, 0, h, bmp_buffer, (LPBITMAPINFO) &bih, DIB_RGB_COLORS);
::ReleaseDC(NULL,hDesktopDC);
DeleteDC(hCaptureDC);
DeleteObject(hCaptureBitmap);
}