[C#] - Problème avec GetMonitorInfo
Bonjour,
Je tente de déterminer les information lié a un moniteur :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
internal class Win
{
...
[DllImport("user32.dll", EntryPoint = "MonitorFromPoint") ]
public static extern IntPtr MonitorFromPoint(POINT pt, uint dwFlags);
[DllImport("user32.dll", EntryPoint = "GetMonitorInfo", SetLastError=true) ]
public static extern bool GetMonitorInfo( IntPtr hMonitor, ref MonitorInfo lpmi );
public const uint MONITOR_DEFAULTTONULL = 0x00000000;
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public long left;
public long top;
public long right;
public long bottom;
}
[StructLayout(LayoutKind.Sequential)]
public struct MonitorInfo
{
public UInt32 cbSize;
public RECT rcMonitor;
public RECT rcWork;
public UInt32 dwFlags;
}
....
} |
Et dans ma fenêtre :
Code:
1 2 3 4 5 6 7
|
bool result;
int errorCode;
IntPtr hPtr = Win.MonitorFromWindow( this.Handle, Win.MONITOR_DEFAULTTONULL );
if ( hPtr != IntPtr.Zero )
result = Win.GetMonitorInfo( hPtr, ref mi );
errorCode = Marshal.GetLastWin32Error(); |
J'obtiens toujours le code 87, ce qui sigifie : The parameter is incorrect.
Quelqu'un pourrait m'éclairer sur ce qui ne fonctionne pas ?
Merci