如何在Windows中强制进行显示检测? [英] How can I force display detection in Windows?
问题描述
我经常用附加的KVM切换器将Windows 7 PC引导到另一台计算机上来启动.当我切换到启动的PC时,显示分辨率错误(并且未检测到第二台连接的显示器).
I often boot my Windows 7 PC with the attached KVM switch focused on another computer. When I switch to the booted PC, the display resolution is wrong (and the second attached monitor is not detected).
我可以通过右键单击桌面,选择Screen Resolution
并单击Detect
来更正此问题.这使Windows可以检测连接的显示器并调整为最佳分辨率.
I can correct this by right-clicking the desktop, choosing Screen Resolution
and clicking Detect
. This makes Windows detect attached displays and adjust to the most optimal resolution.
我想编写一个小的实用程序来自动执行此操作.我应该使用哪个Win32 API调用或C#对象?
I would like to write a small utility to do this automatically. Which Win32 API call or C# object should I use?
推荐答案
您可以尝试:
- 您可以使用Spy ++搜索打开的窗口,并查看它们的属性和消息.
- 使用过程启动"rundll32.exe shell32.dll,Control_RunDLL desk.cpl",或尝试直接调用它以查看是否可以获得窗口句柄,请查看下面的链接以获取想法.
- 使用代码将按钮发送到外部外部应用程序" ,并对其进行修改以搜索标题为屏幕分辨率"的窗口,并向标题为检测"标题的子窗口发送BN_CLICK.
- 由于计算机已经启动,因此您可能需要在登录时自动将其启动,为此请使用任务计划程序.
- You can use Spy++ to search for the windows that are open and take a look at their properties and messages.
- Use process to start "rundll32.exe shell32.dll,Control_RunDLL desk.cpl" or experiment with calling it directly to see if you can get a window handle, check below link for ideas.
- Use the code "send button click to external app" and modify it to search for a window with caption "Screen Resolution" and send a BN_CLICK to the childwindow with the caption "Detect".
- Since the computer is already on you might want to fire it up automatically on logon, for that use the task scheduler.
这篇关于如何在Windows中强制进行显示检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!