本文主要介绍.NET(C#)中通过Process调用SetRes.exe命令修改屏幕显示器分辨率方法代码。

1、SetRes下载

下载地址https://www.softpedia.com/get/Multimedia/Video/Other-VIDEO-Tools/Ian-Sharpe-SetRes.shtml

2、修改单屏代码

将下载的SetRes.exe拷到当前目录即可

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/c setres h1920 v1080";
process.StartInfo = startInfo;
process.Start();

3、修改双屏代码

将下载的SetRes.exe拷到当前目录即可

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/c SETRES m0:0 h1366 v768 && SETRES m1:0 h1280 v800";
process.StartInfo = startInfo;
process.Start();

相关文档:.NET(C#)调用cmd.exe(dos命令)两种方法(Process,Cli)

推荐文档