编程改变"演示显示模式" [英] Programmatically changing the "presentation display mode"
问题描述
在演示显示模式是那些你使用<大骨节病>窗口骨节病> + <大骨节病> P 骨节病>快捷方式时,会看到:
The presentation display modes are those you see when using the Windows+p shortcut:
- 计算机只有
- 复制
- 扩展
- 投影机只有
- Computer Only
- Duplicate
- Extend
- Projector Only
做任何API调用存在允许一到这些显示模式之间切换?
Do any API calls exist which allow one to switch between these display modes?
我想以编程显示器和HDMI电视之间进行切换(一堆其他的事情同时做,因此<大骨节病>窗口骨节病> + <大骨节病> p 骨节病>不是有用的),但我:M击中砖墙
I want to programmatically switch between monitor and HDMI TV (and do a bunch of other things simultaneously, hence Windows+p not being useful), but I'm hitting a brick wall.
推荐答案
在情况下,EnumDisplaySettingsEx和ChangeDisplaySettingsEx功能不适合你,你也可以使用这个:
In case the EnumDisplaySettingsEx and ChangeDisplaySettingsEx functions do not work for you, you can also use this:
private void SetDisplayMode(DisplayMode mode)
{
var proc = new Process();
proc.StartInfo.FileName = "DisplaySwitch.exe";
switch (mode)
{
case DisplayMode.External:
proc.StartInfo.Arguments = "/external";
break;
case DisplayMode.Internal:
proc.StartInfo.Arguments = "/internal";
break;
case DisplayMode.Extend:
proc.StartInfo.Arguments = "/extend";
break;
case DisplayMode.Duplicate:
proc.StartInfo.Arguments = "/clone";
break;
}
proc.Start();
}
enum DisplayMode
{
Internal,
External,
Extend,
Duplicate
}
这将调用DisplaySwitcher基于所需的配置不同的参数。因此,您可以拨打:
This will call the DisplaySwitcher with different arguments based on the required configuration. You can thus call:
SetDisplayMode(DisplayMode.Extend);
这篇关于编程改变"演示显示模式"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!