Home > Net >  C # how to identify the system is in the locked
C # how to identify the system is in the locked

Time:01-17

The code online,

Using System. The 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;//whether to obtain in the screen saver parameter

///& lt; Summary>
///whether the desktop in the screen saver
///& lt;/summary>
///& lt; Returns>
Public static bool IsScreenSaverRunning ()
{
Bool set=false;
SystemParametersInfo (SPI_GETSCREENSAVERRUNNING, 0, ref set, 0).
The return set;
}

I use in the timer, under win10, under the condition of lock, or return false,

Can you tell me how to solve?
  •  Tags:  
  • C#
  • Related