0
我有一個web服務(asp.net),顯示連接到服務器的顯示器的高度或寬度。但是,當我通過本地主機調用它時,我得到的顯示不正確,它表示當顯示設置爲1280x1024時,它顯示爲1024x768。System.Windows.SystemParameters.PrimaryScreenWidth不正確?
我在這裏錯過了什麼嗎?該代碼非常簡單:
[WebMethod]
public int GetHeight()
{
return (int)System.Windows.SystemParameters.PrimaryScreenHeight;
}
[WebMethod]
public int GetWidth()
{
return (int) System.Windows.SystemParameters.PrimaryScreenWidth;
}
我使用也嘗試:
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
也許有更好的方法來做到這一點?也許我應該將這些值存儲在一個文本文件中,或者有更可靠的方法?也許查詢註冊表設置的分辨率?
您的Web服務是否作爲無法訪問本地桌面的服務運行? – Gabe
你確定他們是以同一用戶身份運行嗎?每個用戶都有自己的顯示設置,因此您需要以與Web服務器相同的用戶身份登錄。 – CodeNaked
@gabe:我相信,是否有我可以檢查/配置的地方? – Prisoner