You might be getting exceptions because OverlayManager.GetPixelFormat sets pixelFormat.Rgb to true before entering the switch case. Make sure you move that statement into the relevant switch cases if you haven't already.
You can use the following function to create FourCC codes:
static int MakeFourCC(int ch0, int ch1, int ch2, int ch3){ return ((int)(byte)(ch0)|((int)(byte)(ch1) << 8)| ((int)(byte)(ch2) << 16) | ((int)(byte)(ch3) << 24));}
Instead of manually adding in formats like the sample does, take a look at the documentation for IDirectDraw7::GetFourCCCodes (Managed equivalent: DirectDraw.Device.FourCCCodes) and IDirectDraw7::EnumSurfaces (Managed equivalent: Couldn't find it!). You should check for a number of pre-defined formats first (e.g. 16 and 32 bits per pixel), then check for all FourCC formats supported by the device.
I'll be away for a while, so I won't be able to modify the original sample to reflect the above method as soon as I want to. In the meantime, feel free to do so yourself [smile].