C# 获取窗口所在屏幕的宽度和高度

using System.Windows.Interop;

using System.Drawing;

IntPtr intPtr = new WindowInteropHelper(this).Handle;

System.Windows.Forms.Screen cur_screen = System.Windows.Forms.Screen.FromHandle(intPtr);

Graphics cur_graph = Graphics.FromHwnd(intPtr);

double dpiXRatio = cur_graph.DpiX / 96;

double dpiYRatio = cur_graph.DpiY / 96;

double twidth = cur_screen.Bounds.Width / dpiXRatio;

double theight = cur_screen.Bounds.Height / dpiYRatio;

你可能感兴趣的:(c#,当前屏幕大小)