获取最大屏幕分辨率并更改分辨率

问题描述:

有人可以通过使用C#、. NET(尤其是Windows应用程序)来帮助我获得显示器的最大屏幕分辨率.
我知道如何更改分辨率,但是我对获取高度x格式的最大值感兴趣,例如:1280 x 768
用户可能具有任何屏幕分辨率范围,但如何获得最大可能的屏幕分辨率,这可能因监视器而异.
为了更改分辨率,我提到了:http://bit.ly/dtZmQS,它工作得很好.

Can anybody help me in getting Maximum Screen Resolution of the monitor by using C#, .NET particularly for windows application.
I got to know how to change the resolution but i m interested in getting maximum values in format Height x With example : 1280 x 768
User might be having any screen resolution range but how to get MAXIMUM possible Screen Resolution which can differ from Monitor to Monitor.
For changing resolution i had referred : http://bit.ly/dtZmQS which worked very well.

看看 ^ ].

我发现这个网站有些混乱,以防万一,这不仅是我. :)

如果向下滚动到代码列表的正下方,则会显示Form的屏幕快照.因此,首先使用以下命令创建一个Form:
2个标签
2个ListBoxes-命名为listDevices(顶部的一个)listSettings(底部的一个)
1个按钮-名为btnSet

然后从站点复制代码并将其粘贴以替换Form1.cs中的代码.

然后将listDevices_SelectedIndexChanged事件处理程序连接到listDevices,然后离开.

如果您喜欢冒险,显然也可以连接btnSet事件处理程序. :-D

祝你好运! :)
Take a look at this[^].

I find this site to be a little confusing, so in case it''s not just me. :)

If you scroll down to just below the code listing there is a screen shot of what the Form should look like. So first create a Form with:
2 Labels
2 ListBoxes - named listDevices (top one) listSettings (bottom one)
1 Button - named btnSet

then copy the code from the site and paste it to replace the code in Form1.cs.

Then hook-up the listDevices_SelectedIndexChanged event handler to listDevices and away you go.

You could obviously hook-up the btnSet event handler too, if you are feeling adventurous. :-D

Good luck! :)


我链接到的代码使您能够获得设备的所有可用分辨率(它们在listSettings中列出)
这些项目包含高度和宽度的分辨率.

您需要做的是,而不是将它们添加到ListBox中,是从每个图中提取数字,将它们与迄今为止找到的最大数字进行比较,如果它们较大,则将它们另存为最大数字,依此类推.

该代码旨在向您显示您想要做的事情是可能的.

如果它不能完全满足您的要求,我感到非常抱歉,但是如果您不能根据该代码推断出您的要求,那么编程可能不是您才能的正确选择.
The code that I linked to enables you to get all the available resolutions for the device (they are listed in listSettings)
These items contain the resolution in height and width.

What you need to do is rather than add them to a ListBox is extract the figures from each, compare them to the largest found so far and if they are bigger save them as the largest, and so on.

The code was intended to show you that what you want to do is possible.

I am dreadfully sorry if it doesn''t do precisely what you require but if you are not able to extrapolate from that code to your requirements then maybe programming is not the correct outlet for your talents.


您可以使用System.Windows.Forms.Screen.GetBounds()来获取总大小.

在此处链接 [
You can use System.Windows.Forms.Screen.GetBounds() to get total size.

Link Here[^] may help.