GetMonitorInfo (user32)
Last changed: -80.79.145.65

.
Summary

C# Signature:

[DllImport("User32.dll")]
static extern bool GetMonitorInfoEx(IntPtr hMonitor, [In, Out] MONITORINFOEX lpmi);

[DllImport("user32.dll")]
static extern bool GetMonitorInfo(IntPtr hMonitor, [In, Out] MONITORINFO lpmi);

User-Defined Types:

MONITORINFOEX

MONITORINFO

Notes:

None.

Tips & Tricks:

System.Windows.Forms.Screen

Sample Code:

[DllImport("user32.dll")]
internal static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, MonitorEnumProc lpfnEnum, IntPtr dwData);

internal delegate bool MonitorEnumProc(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData);

private void EnumMonitors()
{
    EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, MonitorEnumCallBack, IntPtr.Zero);
}

private bool MonitorEnumCallBack(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData)
{
    MONITORINFOEX mon_info = new MONITORINFOEX();
    mon_info.cbSize = (uint)Marshal.SizeOf(mon_info);
    GetMonitorInfo(hMonitor, ref mon_info);
    ///Monitor info is stored in 'mon_info'
    return true;
}

Alternative Managed API:

Consider System.Windows.Forms.Screen.

Documentation