Win32 code to get EDID in Windows XP/7

后端 未结 3 518
野的像风
野的像风 2020-12-06 08:39

I found this page and was unable to get any useful information out of it (it searches the registry for something but never finds it and goes into an infinite loop).

3条回答
  •  春和景丽
    2020-12-06 09:10

    Based on Ofek Shilon's blog post, and tweaked to get all the device IDs (manufacturer ID + product ID strings):

    DISPLAY_DEVICE dd;
    dd.cb = sizeof(dd);
    DWORD dev = 0;  // device index
    int id = 1;        // monitor number, as used by Display Properties > Settings
    
    Str DeviceID;
    
    while (EnumDisplayDevices(0, dev, &dd, 0))
    {
        DISPLAY_DEVICE ddMon;
        ZeroMemory(&ddMon, sizeof(ddMon));
        ddMon.cb = sizeof(ddMon);
        DWORD devMon = 0;
    
        while (EnumDisplayDevices(dd.DeviceName, devMon, &ddMon, 0))
        {
            DeviceID.Sprintf("%s", ddMon.DeviceID);
            DeviceID = DeviceID.Slice(8);
            if (DeviceID.Index("\\") > 0)
                DeviceID = DeviceID.Slice(0, DeviceID.Index("\\"));
    
            printf ("DEVICEID = %s --------\n", DeviceID.utf8());
        }
    
        devMon++;
    
        ZeroMemory(&ddMon, sizeof(ddMon));
        ddMon.cb = sizeof(ddMon);
      }
    
      ZeroMemory(&dd, sizeof(dd));
      dd.cb = sizeof(dd);
      dev++;
    }
    

    N.B. Str here is a custom string class but should be easy to refactor to use anything.

提交回复
热议问题