MonitorFromWindow (user32)
Last changed: -24.12.194.220

.
Summary

C# Constants

const int MONITOR_DEFAULTTONULL = 0;
const int MONITOR_DEFAULTTOPRIMARY = 1;
const int MONITOR_DEFAULTTONEAREST = 2;

C# Signature:

[DllImport("user32.dll")]
static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

[DllImport("user32.dll", SetLastError = false)]
static extern IntPtr GetDesktopWindow();

IntPtr handle = MonitorFromWindow(GetDesktopWindow(), MONITOR_DEFAULTTONEAREST);

Alternative Managed API:

The System.Windows.Forms.Screen class contains all you might need to know about multiple monitors. The SystemInformation class also gives some information about available monitors.

Documentation