之前伤脑筋写过一次在Web中,JS,ActiveXObject去读取显示器数量、分辨率去判断单双屏跳转。
那么在客户端中,用C#去读取硬件信息,更方便更容易!
思路参考代码:
if (Screen.AllScreens.Length == )
{
//此显示器是否为主屏
if (Screen.AllScreens[].Primary)
{
this.Top = Screen.AllScreens[].Bounds.Y;
this.Left = Screen.AllScreens[].Bounds.X;
}
else
{
this.Top = Screen.AllScreens[].Bounds.Y;
this.Left = Screen.AllScreens[].Bounds.X;
}
}
else if (Screen.AllScreens.Length == )
{
this.Top = Screen.AllScreens[].Bounds.Y;
this.Left = Screen.AllScreens[].Bounds.X;
}