Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 控制台应用程序桌面大小_C#_Console_Desktop - Fatal编程技术网

C# 控制台应用程序桌面大小

C# 控制台应用程序桌面大小,c#,console,desktop,C#,Console,Desktop,如何从控制台应用程序获取桌面大小 来自WPF或Windows窗体的常规命令将不起作用,我无法想出解决方案 SystemParameters.VirtualScreenWidth SystemParameters.VirtualScreenHeight SystemInformation.VirtualScreen.Width SystemInformation.VirtualScreen.Height 它们都不起作用将System.Windows添加到系统参数的引用中,将Syst

如何从控制台应用程序获取桌面大小

来自WPF或Windows窗体的常规命令将不起作用,我无法想出解决方案

SystemParameters.VirtualScreenWidth   
SystemParameters.VirtualScreenHeight

SystemInformation.VirtualScreen.Width   
SystemInformation.VirtualScreen.Height

它们都不起作用

将System.Windows添加到系统参数的引用中,将System.Windows.Forms添加到系统信息的引用中。

您需要添加对System.Windows.Forms程序集的引用,以利用SystemInformation.VirtualScreen属性

您可以使用
屏幕
类检查post中的一个来获得大小


你说的“它们都不起作用”是什么意思。你得到的值不正确吗?不,我甚至不能编译它,因为它不能识别这些命令,因为它们不属于控制台应用程序!您需要添加dll引用。对于SystemInformation.VirtualScreen.Width,请添加对System.Windows.Forms的引用。请不要为问题添加答案-如果您得到答案-接受它,如果您找到答案-发布单独的答案(称为)。它无法识别!
Screen Srn=Screen.PrimaryScreen;

int tempWidth=Srn.Bounds.Width;
int tempHeight=Srn.Bounds.Height;
Console.WriteLine("Current Screen width is {0} and height is {1}.", tempWidth, tempHeight);