I am developing a VB application in which i need to know the native resolution of the monitor and not the one set by the user(current resolution). So i need to read the EDID
'Here is a complete solution for everything except for actually setting the resolution. This will read out the native resolution settings from the EDID of the active monitor.
Set WshShell = WScript.CreateObject("WScript.Shell")
Const HKEY_LOCAL_MACHINE = &H80000002 Const DTD_INDEX = 54
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "\root\default:StdRegProv")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor",,48)
For Each objItem in colItems 'Gets active monitor EDID registry path
strKeyPath = "SYSTEM\CurrentControlSet\Enum\" & objItem.PNPDeviceID & "\Device Parameters"
Next
oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,"EDID",arrRawEDID
hor_resolution = arrRawEDID(DTD_INDEX + 2) + (arrRawEDID(DTD_INDEX + 4) And 240) * 16 vert_resolution = arrRawEDID(DTD_INDEX + 5) + (arrRawEDID(DTD_INDEX + 7) And 240) * 16
WshShell.Run "res.exe " & hor_resolution & " " & vert_resolution