I'm trying to do some multi-monitor stuff using Platform Invoke. I've been using http://pinvoke.net to get me started but I've hit a problem where definitions don't agree.
In MONITORINFO (user32) (and MONITORINFOEX (user32)), size is defined as:
public int Size;
But in EnumDisplayMonitors (user32), in the sample code which uses MonitorInfo, we see:
mi.size = (uint)Marshal.SizeOf(mi);
Clearly, one of these is less than correct.
In the MSDN docs, MONITORINFO is declared as:
typedef struct tagMONITORINFO {
DWORD cbSize;
RECT rcMonitor;
RECT rcWork;
DWORD dwFlags;
} MONITORINFO, *LPMONITORINFO;
with cbSize defined as:
The size of the structure, in bytes.
Set this member to sizeof ( MONITORINFO ) before calling the GetMonitorInfo function. Doing so lets the function determine the type of structure you are passing to it.
Any idea how I can work out which it should be, int or uint?
Note: I know some of this stuff is available in System.Windows.Forms but I'm trying to do this using P/Invoke in Silverlight 5.