2014-05-01 3 views
1

실제 이름을 반환 할 때 몇 대의 모니터가 연결되어 있습니다 (예 : LEN L192p, IBM 190p).EnumDisplayDevices 반환 값은 일반 PnP 모니터입니다 - C#

How do I get the actual Monitor name? as seen in the resolution dialog

을하지만 난 그것을 실행할 때, 내가 잘못 식별을 얻을 :

이 질문에 여기 보았습니다. 그것은 내 랩톱을 감지하지만 사용하고있는 다른 두 화면 (LEN L192p, IBM 190p)은 감지되지 않고 대신 Generic PnP Monitor을 작성합니다.

누구든지 문제를 알 수 있습니까? enter image description here

및 코드 :

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.InteropServices; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 



namespace Screens 
{ 
    class Program 
    { 


     [DllImport("user32.dll")] 
     public static extern bool EnumDisplayDevices(string lpDevice, uint iDevNum, ref DISPLAY_DEVICE lpDisplayDevice, uint dwFlags); 

     [Flags()] 
     public enum DisplayDeviceStateFlags : int 
     { 
      /// <summary>The device is part of the desktop.</summary> 
      AttachedToDesktop = 0x1, 
      MultiDriver = 0x2, 
      /// <summary>The device is part of the desktop.</summary> 
      PrimaryDevice = 0x4, 
      /// <summary>Represents a pseudo device used to mirror application drawing for remoting or other purposes.</summary> 
      MirroringDriver = 0x8, 
      /// <summary>The device is VGA compatible.</summary> 
      VGACompatible = 0x16, 
      /// <summary>The device is removable; it cannot be the primary display.</summary> 
      Removable = 0x20, 
      /// <summary>The device has more display modes than its output devices support.</summary> 
      ModesPruned = 0x8000000, 
      Remote = 0x4000000, 
      Disconnect = 0x2000000 
     } 

     [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] 
     public struct DISPLAY_DEVICE 
     { 
      [MarshalAs(UnmanagedType.U4)] 
      public int cb; 
      [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] 
      public string DeviceName; 
      [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] 
      public string DeviceString; 
      [MarshalAs(UnmanagedType.U4)] 
      public DisplayDeviceStateFlags StateFlags; 
      [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] 
      public string DeviceID; 
      [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] 
      public string DeviceKey; 
     } 


     static void Main(string[] args) 
     { 

      var device = new DISPLAY_DEVICE(); 
      device.cb = Marshal.SizeOf(device); 
       try 
       { 
        for (uint id = 0; EnumDisplayDevices(null, id, ref device, 0); id++) 
        { 
         device.cb = Marshal.SizeOf(device); 
         EnumDisplayDevices(device.DeviceName, 0, ref device, 0); 
         device.cb = Marshal.SizeOf(device); 

         Console.WriteLine("id={0}, name={1}, devicestring={2}", id, device.DeviceName, device.DeviceString); 
         if (device.DeviceName == null || device.DeviceName == "") continue; 
        } 
        string x = Console.ReadLine(); 
       } 






      catch (Exception ex) 
      { 
       Console.WriteLine(String.Format("{0}", ex.ToString())); 
      } 



} 

답변

1

화면의 아무 드라이버가 설치되지 않은, 따라서 실제 장치 자체가 일반 PnP 모니터 드라이버로 실행되고 있기 때문에이 문제가 발생 여기

이 출력됩니다. 장치 관리자를 보면 알 수 있습니다.

메신저 확실히 제조 업체의 모니터 드라이버를 설치하지 않고도 달성하려는 방법을 얻을 수있는 방법이 없습니다.

+2

지금 장치 관리자를보고 그 내용을 보았습니다. 하지만 (제어판에서) 화면 해상도를 보면이 이름을 볼 수 있습니다. 이 이름을 얻는 방법이 있습니까? – user1386966

+0

@ user1386966 나는 그렇게 생각하지 않는다. 적어도 나는 그것을 발견 할 수있다. – Ashigore