最近研究在Windows中多屏幕显示时,如何切换显示模式:仅电脑屏幕、复制、扩展、仅第二屏幕,有两种方案。
1、通过系统自带的DisplaySwitch.exe,在C:\Windows\System32中,不过要拷贝到程序当前目录调用,不然会提示无法找到文件:
using (var proc = new Process())
{
proc.StartInfo.FileName = @"DisplaySwitch.exe";
proc.StartInfo.Arguments = "/external";
proc.Start();
}
proc.StartInfo.Arguments为传递的参数,共计有四种,可实现屏幕切换。
2、调用Windows API:SetDisplayConfig