重新开一个帖子。现在我还是想要读取显示器的尺寸,我用VC程序读取我PC的屏幕尺寸会随着分辨率的改变而改变,我现在改用EVC去读取触摸屏的显示器尺寸,因为触摸屏的分辨率是不用改变的。但是我读出来的结果都是一个,无论用哪个屏;代码如下:
CString str1,str2,str3;
HDC hScreenDC=CreateDC(_T("DISPlAY"), NULL, NULL, NULL);
m_Width = GetDeviceCaps(hScreenDC,HORZSIZE); //结果是64
m_Highth = GetDeviceCaps(hScreenDC,VERTSIZE); //结果是60
m_DSize=sqrt(m_Width*m_Width+m_Highth*m_Highth)/25.4;
str1.Format(_T("%d"),m_Width);
str2.Format(_T("%d"),m_Highth);
str3.Format(_T("%f"),m_DSize);
SetDlgItemText(IDC_EDIT1,str1);
SetDlgItemText(IDC_EDIT2,str2);
SetDlgItemText(IDC_EDIT3,str3);
无论哪个屏m_Width和m_Highth都是64和60(mm)。这显然是不对的,所以我也不知道改怎么弄了,莫非不用API函数去读取吗?哪位仁兄不是很忙的情况下,帮小弟弄弄这个问题,因为这个问题在网上也没有一个答案。虽然我的分数不多了,但是希望大家以学习为第一,谢谢了呵呵
CString str1,str2,str3;
HDC hScreenDC=CreateDC(_T("DISPlAY"), NULL, NULL, NULL);
m_Width = GetDeviceCaps(hScreenDC,HORZSIZE); //结果是64
m_Highth = GetDeviceCaps(hScreenDC,VERTSIZE); //结果是60
m_DSize=sqrt(m_Width*m_Width+m_Highth*m_Highth)/25.4;
str1.Format(_T("%d"),m_Width);
str2.Format(_T("%d"),m_Highth);
str3.Format(_T("%f"),m_DSize);
SetDlgItemText(IDC_EDIT1,str1);
SetDlgItemText(IDC_EDIT2,str2);
SetDlgItemText(IDC_EDIT3,str3);
无论哪个屏m_Width和m_Highth都是64和60(mm)。这显然是不对的,所以我也不知道改怎么弄了,莫非不用API函数去读取吗?哪位仁兄不是很忙的情况下,帮小弟弄弄这个问题,因为这个问题在网上也没有一个答案。虽然我的分数不多了,但是希望大家以学习为第一,谢谢了呵呵
SM_CXSCREEN, SM_CYSCREEN Width and height, in pixels 用这两个参数可以得到屏幕以像素点的高度和宽度.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY\Default_Monitor\5&3a7255c5&0&11223344&01&00\Device Parameters
如果你的系统可得显示器的EDID,就有EDID项,否则有BAD_EDID项
Reading the EDID for the Current Monitor
Your display driver or mini-VDD can use the EDID structure returned to the VDD at boot time by retrieving this structure from the registry. This can be done once your display driver (or mini-VDD) has called VDD_GET_DISPLAY_CONFIG (or VDD_GetDisplayInfo if your mini-VDD is issuing the call from ring 0). To retrieve the EDID for the current monitor:
1. Get and save the diMonitorDevNodeHandle member of the DISPLAYINFO structure.
2. Call CONFIGMG_Read_Registry_Value. Make sure that you have CONFIGMG.INC in your include directory. The parameters for the call should be as follows:
Parameter
Value
dnDevNode
diMonitorDevNodeHandle retrieved from the DISPLAYINFO
pszSubKey
NULL (no subkey needed)
pszValueName
A pointer to the ASCIIz string "EDID"
ulExpectedType
REG_BINARY
Buffer
A pointer to a 128 byte buffer (the EDID plus the null terminator) which will receive the EDID data back
pulLength
Size of Buffer (129 bytes or longer)
ulFlags
CM_REGISTRY_HARDWARE
就可以得出显示器的尺寸
http://hi.baidu.com/zebf/blog/item/2c8717d5ec3dacc151da4baf.html
Windows Driver Kit: Display Devices
VideoPortDDCMonitorHelperThe VideoPortDDCMonitorHelper function queries a monitor for EDID information using the DDC protocol.BOOLEAN VideoPortDDCMonitorHelper( IN PVOID HwDeviceExtension, IN PVOID DDCControl, __inout PUCHAR EdidBuffer, IN ULONG EdidBufferSize );Parameters
HwDeviceExtension
Pointer to the miniport driver's device extension.
DDCControl
Pointer to a DDC_CONTROL structure.
EdidBuffer
Pointer to a buffer in which the video port driver returns the EDID structure. For ACPI devices, the first four bytes are preset by the video port driver to indicate an attempt to read the EDID.
EdidBufferSize
Specifies the size in bytes of the buffer to which EdidBuffer points.
http://msdn.microsoft.com/en-us/library/aa479182.aspx