最近做的項目發佈後要做自適應,最大化後要鋪滿全屏(不覆蓋任務欄),那麼就需要獲取工作區的大小,代碼如下:
int width = System.Windows.Forms.SystemInformation.WorkingArea.Width;
int height= System.Windows.Forms.SystemInformation.WorkingArea.Height;
Debug.Log(width+","+height);
經測試:
- 任務欄正常顯示的話,工作區寬高爲:1920*1040
- 使用小任務欄按鈕的話,工作區寬高爲:1920*1050
使用到的dll:(我用的是基於.net4.x的dll,dll下載地址:https://download.csdn.net/download/weixin_39766005/11660884)
- System.Drawing.dll;
- System.Windows.Forms.dll;