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