1

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;
}
Martin M
  • 463
  • 8
  • 20

1 Answers1

0

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

Ofek Shilon
  • 14,734
  • 5
  • 67
  • 101
  • As far as I can see your example uses the registry to read the EDID, which I have already tried without success. – Martin M Feb 01 '13 at 11:17
  • Did you search the registry yourself? The exact registry path varies greatly among systems, and SetupAPI is the official way of retrieving the right one. – Ofek Shilon Feb 01 '13 at 17:07
  • I did use the SetupAPI to find the registry path, but when dealing with WinPE you can't get any usefull information from the registry because the drivers don't provide any information. – Martin M Feb 04 '13 at 08:09
  • Jumping on an old conversation here - I was able to get your setup api code working in c# using pinvoke, but I can only get the monitor dimensions. Is there any guide as to how to interpret the EDID byte array using c# or even c++? I don't understand enough about bit shifting to understand the official EDID documentation – mccow002 Feb 10 '15 at 18:06