C++查看显卡支持的分辨率
我正在编写一个小程序,让我来回切换分辨率,因为我的投影仪无法处理与屏幕相同的分辨率。我已经知道如何使用 Windows API 设置屏幕分辨率。以及使用 Windows API 或 QT4 工具包读取当前分辨率。我的问题是我想要一个包含屏幕和显卡支持的所有不同分辨率的菜单。该程序将被分发,因此我需要该程序实际与显卡通信以找出它支持的内容。我想要使用的唯一 API 是 Windows API 或 QT4 工具包,但我不认为 QT4 会这样做,除非您以奇怪的方式使用图形小部件。
我非常确定使用 WINDOWS API 可以实现这一点。我只是不知道该怎么做。
哦,请放宽我的要求,我熟悉 QT4 和 C++,但我通常是一名 Linux 程序员,我是为别人写这篇文章的。我用 Windows API 做过的唯一一件事就是制作一个消息框、设置背景和使用系统变量。所以请简单解释一下这个过程。请不要只发布 msdn 的链接,我讨厌他们的文档,而且我讨厌 Microsoft。我一年可能使用两次窗户。
I am writing a small program to let me switch my resolution back and forth because my projector cannot handle the same resolution as my screen. I already know how to set the screen resolution using the windows API. As well as read the current resolution using the windows API or the QT4 toolkit. My problem is I want a menu of all of the different resolutions supported by the screen and graphics card. This program will be distributed so I need the program to actually communicate to the graphics card to find out what it supports. The only API I want to use is the windows API, or the QT4 toolkit, but I don't think QT4 does that unless you are using the graphics widgets in odd ways.
I am pretty sure this is possible with the WINDOWS API. I just don't know how to do it.
Oh and please cut me some slack, I am familiar with QT4 and C++ but I am typically a Linux programmer, I am writing this for someone else. The only thing I have ever done with the windows API is make a message box, set the background, and used system variables. So please explain the process simply. Please don't just post a link to the msdn, I hate their documentation, and I hate Microsoft. I use windows maybe twice a year.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在一般情况下,以下内容可能适合您
这应该打印出运行 .exe 的当前显示器上所有支持的分辨率。假设您没有使用多显示器显卡,这应该可以工作。否则,您必须在每个显示器上使用 EnumDisplayDevices 循环。
一旦确定了您想要的分辨率,您就可以使用“ChangeDisplaySettingsEx”将显示更改为您想要的模式。
使用 DirectX 是可能的,但我不推荐它,因为代码要复杂得多(必须初始化 DirectX 并使用 COM 指针),除非您计划实际使用 DirectX 不仅仅是确定显示分辨率。
The following should probably work for you in the general case
This should print out all the supported resolutions on the current display that the .exe is running on. Assuming you're not dealing with a multi-display graphics card this should work. Otherwise you'd have to use EnumDisplayDevices loop over each display.
Once you figure out what resolution you want you can use 'ChangeDisplaySettingsEx' to change the display to the mode you want.
Using DirectX is possible but I wouldn't recommend it as the code is alot more complicated (having to initialize DirectX and using COM pointers) unless you plan to actually use DirectX for more than just determining display resolutions.
EnumDisplaySettings :)
来自 MSDN:
“获取当前显示设置,请将 iModeNum 参数中的 ENUM_CURRENT_SETTINGS 常量传递给 EnumDisplaySettings API,如以下 C++ 代码所示。”
EnumDisplaySettings :)
From MSDN:
"To obtain the current display settings, pass the ENUM_CURRENT_SETTINGS constant in the iModeNum parameter to the EnumDisplaySettings API, as illustrated by the following C++ code."