示例#1
0
        private void LoadBasicInfo()
        {
            this.Clear();
            Native.DISPLAY_DEVICE d = new Native.DISPLAY_DEVICE();
            d.cb = Marshal.SizeOf(d);
            try
            {
                for (uint id = 0; Native.Methods.EnumDisplayDevices(null, id, ref d, 0); id++)
                {
                    if (d.StateFlags.HasFlag(Native.DisplayDeviceStateFlags.AttachedToDesktop))
                    {
                        Display display = new Display();
                        this.Add(display);
                        display.Id          = id;
                        display.Name        = d.DeviceName;
                        display.Description = d.DeviceString;
                        display.State       = d.StateFlags;
                        display.DeviceId    = d.DeviceID;
                        display.RegistryKey = d.DeviceKey;

                        d.cb = Marshal.SizeOf(d);
                        Native.Methods.EnumDisplayDevices(d.DeviceName, 0, ref d, 0);
                        display.NameExtended        = d.DeviceName;
                        display.DetailedDescription = d.DeviceString;
                    }
                    d.cb = Marshal.SizeOf(d);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("{0}", ex.ToString()));
                throw ex;
            }
        }
示例#2
0
 internal static extern bool EnumDisplayDevices(string lpDevice, uint iDevNum, ref DISPLAY_DEVICE lpDisplayDevice, uint dwFlags);