您可以使用SystemInformation类的ScreenLock属性来判断屏幕是否被锁定。以下是一个示例代码:

using System;
using System.Windows.Forms;

public class Program
{
    public static void Main()
    {
        bool isLocked = SystemInformation.ScreenLock;
        
        if(isLocked)
        {
            Console.WriteLine("屏幕已锁定");
        }
        else
        {
            Console.WriteLine("屏幕未锁定");
        }
    }
}

请注意,此代码需要在Windows Forms应用程序中运行。如果您正在使用其他类型的应用程序,可能需要进行相应的修改。

winform 判断屏幕是否锁定

原文地址: https://www.cveoy.top/t/topic/ioNM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录