Skip to content

nefarius/Nefarius.Utilities.SessionNotification

Repository files navigation

Nefarius.Utilities.SessionNotification

Build status Requirements Nuget Nuget

Utility classes to get notified about session state changes on Windows.

Examples

using Nefarius.Utilities.SessionNotification;

// subscribe to all sessions (required when run as Windows service)
var sch = new SessionChangeHandler(true);

// session locked event (Win + L)
sch.SessionLock += id =>
{
    var username = SessionUtilities.GetUsernameBySessionId(id, false);
    Console.WriteLine($"Session ID {id}, user {username} locked");
};

// session unlocked event
sch.SessionUnlock += id =>
{
    var username = SessionUtilities.GetUsernameBySessionId(id, false);
    Console.WriteLine($"Session ID {id}, user {username} unlocked");
};

About

Utility classes to get notified about session state changes on Windows.

Resources

License

Stars

Watchers

Forks

Languages