How to fetch the NATIVE resolution of attached monitor from EDID file through VB6.0?

后端 未结 3 2014
春和景丽
春和景丽 2021-01-07 06:35

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

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-07 07:08

    '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

提交回复
热议问题