Hello Friends,
The following code shows you how to lock and unlock a folder. User can browse the specific folder to lock/Unlock it.
SystemEvents in using Microsoft.Win32 namespace Provides access to system event notifications.
static void Main(string[] args)
{
SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);
Console.ReadLine();
}
static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
if (e.Reason == SessionSwitchReason.SessionLock)
{
Console.WriteLine("lock");
}
else if (e.Reason == SessionSwitchReason.SessionUnlock)
{
Console.WriteLine("Unlock");
}
}
Comments
Post a Comment