Shutdown, hibernate, sleep, logout, automatic logout.

  • Thread starter Thread starter Katit
  • Start date Start date
K

Katit

How do I detect those? Shutdown seem to be fine, it fires Form events
and app shuts down properly.

I need to detect when system locks up or other events happen. This is
TCP/IP app and I need to notify oser users of this happening.

Thanks!
 
How do I detect those? Shutdown seem to be fine, it fires Form events
and app shuts down properly.

Look at the Microsoft.Win32.SystemEvents class, particularly the
PowerModeChanged and SessionEnding events.

static void Main()
{
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
}

static void SystemEvents_PowerModeChanged(object sender,
PowerModeChangedEventArgs e)
{
if (e.Mode == PowerModes.Suspend)
{
Console.WriteLine("Suspending!");
}
}

Michael
 
Back
Top