Detect When WIndows is Locked/Unlocked

Does anyone know if there is a way to detect when the user locks or unlocks there windows PC.

You can find here some functions to receive notification when the user locks or unlocks the computer.

Does anyone know if this is possible via the MBS_WIN plugin I just tried

  const WM_LOCK=&h7
  const WM_UNLOCK=&h8
  call w.ListenForMessage WM_LOCK
  call w.ListenForMessage WM_UNLOCK

Did not work but I don’t think thats the right notification listener for session related events.

you need to listen for WM_WTSSESSION_CHANGE (&h02B1).

see
https://msdn.microsoft.com/en-us/library/aa383828(v=vs.85).aspx

than check wParam for being WTS_SESSION_LOCK (7) or WTS_SESSION_UNLOCK (8).