網上查了代碼,
using System.Runtime.InteropServices;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern bool SystemParametersInfo(
int uAction, int uParam, ref bool lpvParam,
int flags);
private const int SPI_GETSCREENSAVERRUNNING = 114; //獲取是否處于屏保引數
/// <summary>
/// 桌面是否處于屏保
/// </summary>
/// <returns></returns>
public static bool IsScreenSaverRunning()
{
bool isRunning = false;
SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref isRunning, 0);
return isRunning;
}
我用在timer里面,在win10下,在鎖定情況下,還是回傳false。
請問如何解決?
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/249654.html
標籤:C#
