win32: get current DEVMODE of a monitor
How can I get the current resolution in win32? I know I can use GetMonit开发者_StackOverflow中文版orInfo
to get the current bounding rectangle of the monitor, but how can I also get the bit-depth? Pretty much, how do I get the DEVMODE
struct of a given monitor?
I'm using python and pywin32, so solutions addressing those specifically are nice, but just the winapi calls will do.
In addition to the EnumDisplayMonitors function mentioned in Dean's answer you need GetDeviceCaps(). See parameter BITSPIXEL: it gives you the number of adjacent color bits for each pixel.
You'll want to use the EnumDisplayMonitors function, which calls a callback for each monitor and passes the rectangle and a device context (which includes the colour information).
pywin32 has win32api.EnumDisplayMonitors, which appears to use EnumDisplayMonitors under the covers to return a list with the same details as I mentioned above.
精彩评论