Read EDID direct from monitor NO drivers

3.5k Views Asked by At

I got this project where I'm trying to extract the directly from the monitor. The goal is to make a application which can run on without any drivers installed. I know it is possible to get the information with the registration database or , but this is not possible in this project because it won't provide the correct information without drivers installed. We got this attached code that works, but I guess it asks the drivers for the resolutions, because it won't work when we try on a installation. Here's the code that can display the resolutions, when the drivers are installed..

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool EnumDisplaySettings([MarshalAs(UnmanagedType.LPStr)] string lpszDeviceName, int iModeNum, out Program.DEVMODE lpDevMode);
public static List<Tuple<int, int>> GetScreenResolutions()
{
    List<Tuple<int, int>> list = new List<Tuple<int, int>>();
    try
    {
        int num = 0;
        Program.DEVMODE dEVMODE;
        while (Program.EnumDisplaySettings(null, num++, out dEVMODE))
        {
            Tuple<int, int> item = Tuple.Create<int, int>(dEVMODE.dmPelsWidth, dEVMODE.dmPelsHeight);
            if (!list.Contains(item))
            {
                list.Add(item);
            }
        }
    }
    catch
    {
        Console.WriteLine("Could not get screen resolutions.");
    }
    return list;
}
1

There are 1 best solutions below

4
On

You might need to P/Invoke to the native SetupAPI. Haven't tested the code in the link on winpe, though.