سلام بر برنامه نویسان عزیز 😉 در این مطلب آموزش شمارش تعداد مانیتورها با استفاده از user32.dll در #C را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
کد شمارش تعداد مانیتورها با استفاده از user32.dll در #C :
''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
{
delegate bool MonitorEnumDelegate( IntPtr hMonitor,IntPtr hdcMonitor,ref Rect lprcMonitor, IntPtr dwData );
[ DllImport( "user32.dll" ) ]
static extern bool EnumDisplayMonitors( IntPtr hdc, IntPtr lprcClip, MonitorEnumDelegate lpfnEnum, IntPtr dwData );
[ DllImport( "user32.dll" ) ]
static extern bool GetMonitorInfo( IntPtr hmon, ref MonitorInfo mi );
static bool MonitorEnum( IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData )
{
MonitorInfo mi = new MonitorInfo();
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
{
delegate bool MonitorEnumDelegate( IntPtr hMonitor,IntPtr hdcMonitor,ref Rect lprcMonitor, IntPtr dwData );
[ DllImport( "user32.dll" ) ]
static extern bool EnumDisplayMonitors( IntPtr hdc, IntPtr lprcClip, MonitorEnumDelegate lpfnEnum, IntPtr dwData );
[ DllImport( "user32.dll" ) ]
static extern bool GetMonitorInfo( IntPtr hmon, ref MonitorInfo mi );
static bool MonitorEnum( IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData )
{
MonitorInfo mi = new MonitorInfo();