I'm using the .开发者_StackOverflow中文版NET CF 2.0 on multiple devices which have different display capabilities (specifically color/monochrome) that I'd like to determine at run-time but can't find any methods that provide access to this information.
P/Invoke GetDeviceCaps with COLORRES for the nIndex value.
Edit 1
This gives you color depth, but not actual "color" versus "monochrome". That one is actually not provided anywhere because it's not actually important at that level.
Generally you can look at color depth and say that if it's 8-bit or less, its very, very likely to be greyscale. Greater is likely to be color.
Of course the OEM could have used a 16bpp driver on a monochrome display. There's no reason you can't do it, it's just really inefficient wasteful becasue the monochrome hardware doesn't have any wires or provisions for the extra bits, so they just get dumped on the floor.
If you need to really, really know if it's color or monochrome, the only reliable way to know is to actually ask the user via a setting.
To get this information, you need to P/Invoke GetDC() and GetDeviceCaps(). Here's your link:
http://blogs.msdn.com/davidklinems/archive/2005/02/02/366042.aspx
精彩评论