可能重複:
How do I determine the true pixel size of my Monitor in .NET?獲得監測物理尺寸
如何讓顯示器大小我的意思是它的或物理尺寸如何寬度和高度,對角線例如17英寸什麼
我不需要分辨率,我試過
using System.Management ;
namespace testscreensize
{
class Program
{
static void Main(string[] args)
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("\\root\\wmi", "SELECT * FROM WmiMonitorBasicDisplayParams");
foreach (ManagementObject mo in searcher.Get())
{
double width = (byte)mo["MaxHorizontalImageSize"]/2.54;
double height = (byte)mo["MaxVerticalImageSize"]/2.54;
double diagonal = Math.Sqrt(width * width + height * height);
Console.WriteLine("Width {0:F2}, Height {1:F2} and Diagonal {2:F2} inches", width, height, diagonal);
}
Console.ReadKey();
}
}
}
它給錯誤
類型或命名空間名稱'ManagementObjectSearcher'
找不到
,它適用於僅適用於Vista,我需要更廣泛的解決方案
我也試過
Screen.PrimaryScreen.Bounds.Height
但它返回的分辨率爲
GetDeviceCaps可能會有所幫助。請參閱http://msdn.microsoft.com/en-us/library/dd144877(v=vs.85).aspx – hsmiths 2011-06-15 20:21:37
顯示器的像素和真實尺寸之間完全不同, – AMH 2011-06-15 20:22:20