溫馨提示×

c# enumdisplaymonitors如何處理多顯示器

c#
小樊
107
2024-12-07 19:20:48
欄目: 編程語言

在C#中,要處理多顯示器,可以使用System.Windows.Forms.Screen

using System;
using System.Windows.Forms;

namespace MultipleMonitorsExample
{
    class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // 獲取所有顯示器
            Screen[] screens = Screen.AllScreens;

            // 遍歷所有顯示器并顯示它們的信息
            foreach (Screen screen in screens)
            {
                Console.WriteLine($"Screen: {screen.DeviceName}");
                Console.WriteLine($"Bounds: {screen.Bounds}");
                Console.WriteLine($"Working Area: {screen.WorkingArea}");
                Console.WriteLine();
            }

            Console.ReadKey();
        }
    }
}

這個示例將輸出所有連接的顯示器的信息,包括設備名稱、邊界和工作區域。你可以根據需要修改代碼以滿足你的需求。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女