Search code examples
pythonwinapimonitorpywin32

win32: get current DEVMODE of a monitor


How can I get the current resolution in win32? I know I can use GetMonitorInfo 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.


Solution

  • 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.