Double buffering Gdiplus and GDI I have this working code and was wondering how I can optimize it. Is there anything I can declare globally so it does not need to be be created over and over? This function is called around 30 times a second.

bmScreenBuffer is a global Bitmap.

Contents of drawScreen():

// Buffer - Get the main window handle to create 2 dcs (device contexed) 
HWND hwndMain = programInfoPtr-&gt;hWnd;
HDC hdcMain = GetDC(hwndMain);
HDC hdcBuffer = CreateCompatibleDC(hdcMain);

// Current buffer and old
HBITMAP hbm_Buffer = CreateCompatibleBitmap(hdcMain, bmScreenBuffer-&gt;GetWidth(), bmScreenBuffer-&gt;GetHeight());
HBITMAP hbm_oldBuffer = (HBITMAP)SelectObject(hdcBuffer, hbm_Buffer);

// Tells GDI+ to draw to the "GDI" DC
Graphics* g = new Graphics(hdcBuffer);
g-&gt;DrawImage(bmScreenBuffer, 0, 0);

// Now copy the image to the screen
BitBlt(hdcMain, 0, 0, bmScreenBuffer-&gt;GetWidth(), bmScreenBuffer-&gt;GetHeight(), hdcBuffer, 0, 0, SRCCOPY); 

// Clean Up
ReleaseDC(hwndMain, hdcMain);
SelectObject(hdcBuffer, hbm_oldBuffer);
DeleteDC(hdcBuffer);
DeleteObject(hbm_Buffer);
delete g;
There's probably a faster way to grab the display like with DirectX or something. WinGDI (BitBlt) is probably pretty slow.
GetDC has no effect on class or private DCs, so it is always sensible to call ReleaseDC after GetDC.
Watch out GetClassInfoEx function.
HBITMAP hbm_Buffer = CreateCompatibleBitmap(hdcMain, bmScreenBuffer-&gt;GetWidth(), bmScreenBuffer-&gt;GetHeight());: assuming your machine is running in 32-bit color, this generates a 32-bit bitmap (ie: compatible with the current display). Don't use CreateCompatibleBitmap here. Use CreateBitmap instead. Also note that you no longer really need hdcMain for this.
Remember that the Graphics class itself is a managed object and it will be garbage collected sooner or later. This class also uses unmanaged memory, the garbage collector doesn't "see" that memory and doesn't know that the actual memory used by the Graphics class may be much higher than the size of a Graphics instance. But fortunately you did it correctly: it's better to delete such objects as soon as you no longer need them, deleting will free any unmanaged memory or any other resources like opened files.