Well, you are lucky cause i just finished working on a similar project. I don't really feel like rewriting it so you gonna have to take what you can from the code and adapt it to yours. Note that this code support all bit per pixels a bitmap can have(except 24), but you probably only need the 32 or 24 bit one, so just ignore the palette stuffs. Also, ignore the FillScreenshotInfo() and CreateEmpty() functions, but FillBMIHeader() is important to keep. You might also need this code for the cursor part, and this class to calculate the buffer size required for the bitmap(It return the 4-bytes aligned size needed).
Actually, here's a more simple version of the code, but i can't garanty it is 100% bug free (might be missing a ReleaseDC() somewhere, or not).