编程改变"演示显示模式" [英] Programmatically changing the "presentation display mode"

查看:178
本文介绍了编程改变"演示显示模式"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

演示显示模式是那些你使用<大骨节病>窗口 + <大骨节病> P 快捷方式时,会看到:

The presentation display modes are those you see when using the Windows+p shortcut:


  1. 计算机只有

  2. 复制

  3. 扩展

  4. 投影机只有

  1. Computer Only
  2. Duplicate
  3. Extend
  4. 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);

这篇关于编程改变&QUOT;演示显示模式&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆