And here we go. It's rough, and actually interrogates the copy of the EDID info that Windows sticks into the registry after detecting and querying a new Plug and Play monitor being connected rather than directly querying the monitor itself. But it shows (or at least should do) that your monitor does supply it's physical size, and that Windows takes a record of that.
OK, the following declarations in a module:
[tt]
Option Explicit
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const ERROR_SUCCESS = 0
Public Const ERROR_NO_MORE_ITEMS = 259&
Public Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
Public Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
[/tt]
And the following in a form:
[tt]
Option Explicit
Private Sub Form_Load()
Me.Show
MonitorPeek
End Sub
Private Sub MonitorPeek()
Dim hKey As Long
Dim strSubkey As String
Dim cbName As Long
Dim result As Long
Dim Index As Long
Dim MonitorKey As String
Dim DisplayKey As String
Form1.Cls
DisplayKey = "System\CurrentControlSet\Enum\DISPLAY"
RegOpenKeyEx HKEY_LOCAL_MACHINE, DisplayKey, 0, KEY_ENUMERATE_SUB_KEYS, hKey
Debug.Print hKey
strSubkey = Space(1024)
cbName = 1024
Print "Windows has interrogated the following monitors:"
result = RegEnumKey(hKey, Index, strSubkey, cbName)
Do Until result = ERROR_NO_MORE_ITEMS
MonitorKey = Left(strSubkey, InStr(strSubkey, Chr(0)) - 1)
Print MonitorKey
GetMonitorEDID DisplayKey & "\" & MonitorKey
Index = Index + 1
result = RegEnumKey(hKey, Index, strSubkey, cbName)
Loop
RegCloseKey hKey
End Sub
Private Sub GetMonitorEDID(strKey As String)
Dim hKey As Long
Dim strSubkey As String
Dim cbName As Long
Dim result As Long
Dim NewSubKey As String
Dim bBuffer As String * 256
Dim cbBuffer As Long
RegOpenKeyEx HKEY_LOCAL_MACHINE, strKey, 0, KEY_ENUMERATE_SUB_KEYS, hKey
strSubkey = Space(1024)
cbName = 1024
result = RegEnumKey(hKey, 0, strSubkey, cbName)
NewSubKey = Left(strSubkey, InStr(strSubkey, Chr(0)) - 1)
RegCloseKey hKey
RegOpenKeyEx HKEY_LOCAL_MACHINE, strKey + "\" + NewSubKey + "\Device Parameters", 0, KEY_QUERY_VALUE, hKey
cbBuffer = 256
RegQueryValueEx hKey, "EDID", 0&, 0&, bBuffer, cbBuffer
Print Asc(Mid(bBuffer, 22, 1)) * 0.3937 & " x " & Asc(Mid(bBuffer, 23, 1)) * 0.3937 ' centimeters to inches
RegCloseKey hKey
End Sub