I am working on writing a program that will start automatically when the system boots.
and store that information in a DataBase when the computer is shutdown.
In other words, when the computer is shutdown, I show a messagebox for save information. if user click yes, save information in database.
if (MessageBox.Show("Save changes?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
MyFunction();
}
Check this SystemEvents.SessionEnding event.
MSDN Link here