Reputation: 465
I got this c# project where I'm trying to extract the edid directly from the monitor. The goal is to make a application which can run on winpe without any drivers installed. I know it is possible to get the information with the registration database or wmi, 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 winpe 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;
}
Upvotes: 1
Views: 3708
Reputation: 16129
You might need to P/Invoke to the native SetupAPI. Haven't tested the code in the link on winpe, though.
Upvotes: 0