如何從控制檯應用程序獲取桌面大小?控制檯應用程序桌面大小
來自WPF或Windows窗體的常規命令不起作用,我無法想出一個解決方案!
SystemParameters.VirtualScreenWidth
SystemParameters.VirtualScreenHeight
SystemInformation.VirtualScreen.Width
SystemInformation.VirtualScreen.Height
他們沒有工作
如何從控制檯應用程序獲取桌面大小?控制檯應用程序桌面大小
來自WPF或Windows窗體的常規命令不起作用,我無法想出一個解決方案!
SystemParameters.VirtualScreenWidth
SystemParameters.VirtualScreenHeight
SystemInformation.VirtualScreen.Width
SystemInformation.VirtualScreen.Height
他們沒有工作
添加System.Windows爲SystemParameters和System.Windows.Forms的爲SystemInformation引用。
它不承認! –
您需要添加一個引用System.Windows.Forms的組件,以利用SystemInformation.VirtualScreen財產https://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.virtualscreen(v=vs.110).aspx
的ü可以用screen
類檢查後得到一個規模。
http://mytactics.blogspot.ae/2013/12/change-screen-resolution-using-c.html
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);
你說的 '他們沒有工作' 的意思。你得到不正確的值? –
不,我甚至不能編譯它,因爲它不能識別這些命令,因爲它們不屬於控制檯應用程序! –
您需要添加dll引用。對於SystemInformation.VirtualScreen.Width添加對System.Windows.Forms的引用 –