win32:获取监视器的当前DEVMODE
win32下如何获取当前分辨率?我知道我可以使用 GetMonitorInfo
来获取监视器的当前边界矩形,但是我如何才能获取位深度?差不多,我如何获取给定监视器的 DEVMODE
结构?
我使用的是 python 和 pywin32,因此专门解决这些问题的解决方案很好,但只需 winapi 调用即可。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了 Dean 的答案中提到的 EnumDisplayMonitors 函数之外,您还需要 GetDeviceCaps ()。请参阅参数 BITSPIXEL:它为您提供每个像素的相邻颜色位数。
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.
您需要使用EnumDisplayMonitors 函数,它为每个监视器调用回调并传递矩形和设备上下文(其中包括颜色信息)。
pywin32 有 win32api.EnumDisplayMonitors,它似乎在幕后使用 EnumDisplayMonitors返回一个具有与我上面提到的相同详细信息的列表。
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.