From dcdb27e2c02517ce76a05c29bab56e349853ca40 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 5 Feb 2019 14:11:28 -0700 Subject: [PATCH] Added DISPLAY_DEVICE --- PInvoke/Gdi32/WinGdi.cs | 167 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 1 deletion(-) diff --git a/PInvoke/Gdi32/WinGdi.cs b/PInvoke/Gdi32/WinGdi.cs index 05dfd766..e64efa84 100644 --- a/PInvoke/Gdi32/WinGdi.cs +++ b/PInvoke/Gdi32/WinGdi.cs @@ -210,6 +210,67 @@ namespace Vanara.PInvoke BLTALIGNMENT = 119 } + /// Device state flags. + [PInvokeData("wingdi.h", MSDNShortId = "9a7813fe-358a-44eb-99da-c63f98d055c3")] + [Flags] + public enum DISPLAY_DEVICE_FLAGS + { + /// + /// The DISPLAY_DEVICE_ACTIVE specifies whether a monitor is presented as being "on" by the respective GDI view. Windows Vista: + /// EnumDisplayDevices will only enumerate monitors that can be presented as being "on." + /// + DISPLAY_DEVICE_ACTIVE = 0x00000001, + + /// The display device is attached. + DISPLAY_DEVICE_ATTACHED = 0x00000002, + + /// The display device attached to desktop + DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = 0x00000001, + + /// Undocumented. + DISPLAY_DEVICE_MULTI_DRIVER = 0x00000002, + + /// + /// The primary desktop is on the device. For a system with a single display card, this is always set. For a system with multiple + /// display cards, only one device can have this set. + /// + DISPLAY_DEVICE_PRIMARY_DEVICE = 0x00000004, + + /// + /// Represents a pseudo device used to mirror application drawing for remoting or other purposes. An invisible pseudo monitor is + /// associated with this device. For example, NetMeeting uses it. Note that GetSystemMetrics (SM_MONITORS) only accounts for + /// visible display monitors. + /// + DISPLAY_DEVICE_MIRRORING_DRIVER = 0x00000008, + + /// The device is VGA compatible. + DISPLAY_DEVICE_VGA_COMPATIBLE = 0x00000010, + + /// The device is removable; it cannot be the primary display. + DISPLAY_DEVICE_REMOVABLE = 0x00000020, + + /// Undocumented. + DISPLAY_DEVICE_ACC_DRIVER = 0x00000040, + + /// The device has more display modes than its output devices support. + DISPLAY_DEVICE_MODESPRUNED = 0x08000000, + + /// Undocumented. + DISPLAY_DEVICE_RDPUDD = 0x01000000, + + /// Undocumented. + DISPLAY_DEVICE_REMOTE = 0x04000000, + + /// Undocumented. + DISPLAY_DEVICE_DISCONNECT = 0x02000000, + + /// Undocumented. + DISPLAY_DEVICE_TS_COMPATIBLE = 0x00200000, + + /// Undocumented. + DISPLAY_DEVICE_UNSAFE_MODES_ON = 0x00080000, + } + /// Hatch style used by . [PInvokeData("wingdi.h", MSDNShortId = "ded2c7a4-2248-4d01-95c6-ab4050719094")] public enum HatchStyle : uint @@ -314,6 +375,23 @@ namespace Vanara.PInvoke CAPTUREBLT = 0x40000000 } + /// Flags used with region functions. + [PInvokeData("wingdi.h")] + public enum RegionFlags + { + /// An error occurred. + ERROR = 0, + + /// Region is empty. + NULLREGION = 1, + + /// Region is a single rectangle. + SIMPLEREGION = 2, + + /// Region consists of more than one rectangle. + COMPLEXREGION = 3, + } + /// The AlphaBlend function displays bitmaps that have transparent or semitransparent pixels. /// A handle to the destination device context. /// The x-coordinate, in logical units, of the upper-left corner of the destination rectangle. @@ -453,7 +531,7 @@ namespace Vanara.PInvoke /// /// /// ICM: If the DC that is passed to this function is enabled for Image Color Management (ICM), the DC created by the function is - /// ICM-enabled. The source and destination color spaces are specified in the DC. + /// ICM-enabled. The source and destination color spaces are specified in the DC. /// /// [DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)] @@ -742,5 +820,92 @@ namespace Vanara.PInvoke [return: MarshalAs(UnmanagedType.Bool)] [PInvokeData("Wingdi.h", MSDNShortId = "dd145141")] public static extern bool TransparentBlt(HDC hdcDest, int xOriginDest, int yOriginDest, int wDest, int hDest, HDC hdcSrc, int xOriginSrc, int yOriginSrc, int wSrc, int hSrc, int crTransparent); + + /// + /// The DISPLAY_DEVICE structure receives information about the display device specified by the iDevNum parameter of the + /// EnumDisplayDevices function. + /// + /// + /// The four string members are set based on the parameters passed to EnumDisplayDevices. If the lpDevice param is NULL, then + /// DISPLAY_DEVICE is filled in with information about the display adapter(s). If it is a valid device name, then it is filled in + /// with information about the monitor(s) for that device. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-_display_devicea typedef struct _DISPLAY_DEVICEA { DWORD cb; + // CHAR DeviceName[32]; CHAR DeviceString[128]; DWORD StateFlags; CHAR DeviceID[128]; CHAR DeviceKey[128]; } DISPLAY_DEVICEA, + // *PDISPLAY_DEVICEA, *LPDISPLAY_DEVICEA; + [PInvokeData("wingdi.h", MSDNShortId = "9a7813fe-358a-44eb-99da-c63f98d055c3")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct DISPLAY_DEVICE + { + /// Size, in bytes, of the DISPLAY_DEVICE structure. This must be initialized prior to calling EnumDisplayDevices. + public uint cb; + + /// An array of characters identifying the device name. This is either the adapter device or the monitor device. + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] + public string DeviceName; + + /// + /// An array of characters containing the device context string. This is either a description of the display adapter or of the + /// display monitor. + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + public string DeviceString; + + /// + /// Device state flags. It can be any reasonable combination of the following. + /// + /// + /// Value + /// Meaning + /// + /// + /// DISPLAY_DEVICE_ACTIVE + /// + /// DISPLAY_DEVICE_ACTIVE specifies whether a monitor is presented as being "on" by the respective GDI view. Windows Vista: + /// EnumDisplayDevices will only enumerate monitors that can be presented as being "on." + /// + /// + /// + /// DISPLAY_DEVICE_MIRRORING_DRIVER + /// + /// Represents a pseudo device used to mirror application drawing for remoting or other purposes. An invisible pseudo monitor is + /// associated with this device. For example, NetMeeting uses it. Note that GetSystemMetrics (SM_MONITORS) only accounts for + /// visible display monitors. + /// + /// + /// + /// DISPLAY_DEVICE_MODESPRUNED + /// The device has more display modes than its output devices support. + /// + /// + /// DISPLAY_DEVICE_PRIMARY_DEVICE + /// + /// The primary desktop is on the device. For a system with a single display card, this is always set. For a system with multiple + /// display cards, only one device can have this set. + /// + /// + /// + /// DISPLAY_DEVICE_REMOVABLE + /// The device is removable; it cannot be the primary display. + /// + /// + /// DISPLAY_DEVICE_VGA_COMPATIBLE + /// The device is VGA compatible. + /// + /// + /// + public DISPLAY_DEVICE_FLAGS StateFlags; + + /// Not used. + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + public string DeviceID; + + /// Reserved. + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + public string DeviceKey; + + /// Gets an empty structure with the set to the size of the structure. + public static readonly DISPLAY_DEVICE Default = new DISPLAY_DEVICE { cb = (uint)Marshal.SizeOf(typeof(DISPLAY_DEVICE)) }; + } } } \ No newline at end of file