سلام 😉 در این پست کد گرفتن اطلاعات مانیتور » سایز و monitor در سی شارپ #C را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
خروجی این کد به صورت زیر می باشد:
40
Rect
Rect
کد گرفتن اطلاعات مانیتور » سایز و monitor در سی شارپ #C :
/*
Revised from
NET Development for Java Programmers
*/
using System;
using System.Runtime.InteropServices;
[ StructLayout( LayoutKind.Explicit ) ]
struct Point
{
[ FieldOffset( 0 ) ]
public int x;
[ FieldOffset( 4 ) ]
public int y;
}
[ StructLayout( LayoutKind.Sequential ) ]
struct Rect
{
public int left;
public int top;
public int right;
public int bottom;
}
[ StructLayout( LayoutKind.Sequential ) ]
struct MonitorInfo
{
public uint size;
public Rect monitor;
public Rect work;
public uint flags;
}
class MainClass
{
[ DllImport( "user32.dll" ) ]
static extern IntPtr MonitorFromPoint( Point p, uint flags );
[ DllImport( "user32.dll" ) ]
static extern bool GetMonitorInfo( IntPtr hmon, ref MonitorInfo mi );
[STAThread]
static void Main(string[] args)
{
Point p = new Point();
Revised from
NET Development for Java Programmers
*/
using System;
using System.Runtime.InteropServices;
[ StructLayout( LayoutKind.Explicit ) ]
struct Point
{
[ FieldOffset( 0 ) ]
public int x;
[ FieldOffset( 4 ) ]
public int y;
}
[ StructLayout( LayoutKind.Sequential ) ]
struct Rect
{
public int left;
public int top;
public int right;
public int bottom;
}
[ StructLayout( LayoutKind.Sequential ) ]
struct MonitorInfo
{
public uint size;
public Rect monitor;
public Rect work;
public uint flags;
}
class MainClass
{
[ DllImport( "user32.dll" ) ]
static extern IntPtr MonitorFromPoint( Point p, uint flags );
[ DllImport( "user32.dll" ) ]
static extern bool GetMonitorInfo( IntPtr hmon, ref MonitorInfo mi );
[STAThread]
static void Main(string[] args)
{
Point p = new Point();