Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want get monitor name as in control panel. I use this code

C#
DISPLAY_DEVICE lpDisplayDevice = new DISPLAY_DEVICE(0); // OUT
DISPLAY_DEVICE monitor_name = new DISPLAY_DEVICE(0);
int devNum = 0;
while (EnumDisplayDevices(null, (uint)devNum, ref lpDisplayDevice, 0))
  {
     lpDisplayDevice.DeviceName.Trim());
     Console.WriteLine("DeviceString =" + lpDisplayDevice.DeviceString.Trim());
     EnumDisplayDevices(lpDisplayDevice.DeviceName, 0, ref monitor_name, 0);
     Console.WriteLine("Monitor name =" + monitor_name.DeviceString.Trim());
      ++devNum;
 }

but this return me \\.\DISPLAY4 . I watch this topic url msdn[^] but find solution only in c language.
Posted

Quote:
but find solution only in c language


ok, lets assume for the moment that that's all there is .. you could wrap the c language parts into a dll and pinvoke it couldn't you ?

else, since the c code is likely just calling win32 api's anyway, pinvoke them from c# ?
 
Share this answer
 
Comments
[no name] 17-Oct-14 2:21am    
yes. i want use pinvoke
Garth J Lancaster 17-Oct-14 2:27am    
have a look at GalaticJello's response here (he has two ways of doing it) http://stackoverflow.com/questions/18832991/enumdisplaydevices-not-returning-anything
Garth J Lancaster 17-Oct-14 2:28am    
update : this may also be of use http://justlikeamagic.com/2009/05/21/changing-display-settings-programmatically/
[no name] 17-Oct-14 3:03am    
thank you very much, but this threads dont help(
Why don't you try Windows Management Instrumentation (WMI)? That could be much easier (but true: on some comuters, WMI is defect and needs to be repaired...).
 
Share this answer
 
Comments
[no name] 17-Oct-14 6:33am    
its not get monitor name.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900