Screen capture behaviour
===

I use this code to capture the desktop:

    Frame::Frame()
	{
	source_win=GetDesktopWindow();
	RECT r;
	GetWindowRect(source_win,&r);
	width=r.right;
	height=r.bottom;

	source_context=GetDC(source_win);
	sink_context=CreateCompatibleDC(source_context);
	sink_bitmap=CreateCompatibleBitmap(source_context,width,height);
	old_obj=SelectObject(sink_context,sink_bitmap);

	memset(&info_out,0,sizeof(info_out));
	info_out.bmiHeader.biSize=sizeof(info_out.bmiHeader);
	GetDIBits(source_context,sink_bitmap,0,0,NULL,&info_out,DIB_RGB_COLORS);
	info_out.bmiHeader.biBitCount=24;
	info_out.bmiHeader.biCompression=BI_RGB;
	bitmapdata=malloc(getScanlineSize(info_out.bmiHeader.biWidth
		,info_out.bmiHeader.biBitCount)
		*info_out.bmiHeader.biHeight);
	p_rows=(void**)malloc(sizeof(void*)*info_out.bmiHeader.biHeight);
	for(int k=0;k<info_out.bmiHeader.biHeight;k++)
		{p_rows[info_out.bmiHeader.biHeight-k-1]=(char*)bitmapdata + k*getScanlineSize(info_out.bmiHeader.biWidth,info_out.bmiHeader.biBitCount);}
	}

    void Frame::capture()
        {
	BitBlt(sink_context,0,0,width,height,source_context,0,0,SRCCOPY|CAPTUREBLT);
			GetDIBits(sink_context,sink_bitmap,0,info_out.bmiHeader.biHeight
			,bitmapdata,&info_out,DIB_RGB_COLORS);
	}

    Frame::~Frame()
	{
	free(p_rows);
	free(bitmapdata);
	SelectObject(sink_context,old_obj);
	DeleteObject(sink_bitmap);
	DeleteDC(sink_context);
	ReleaseDC(source_win,source_context);
	}


Provided that at least one double buffered application is running, this works well on Windows XP for capturing a fullscreen OpenGL app. However, in Windows 7, it only produces black frames. How to modify the code to get it work again?

If it matters, I am running the 64-bit edition. Detours is not an option due to incompatible license.