private Microsoft.Win32.RegistryKey regkeyScreenSaver;
private object origScreenSaveSetting;
private void Form1_Load(object sender, System.EventArgs e)
{
// Get current screen saver setting
regkeyScreenSaver =
Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Control
Panel").OpenSubKey("Desktop", true);
origScreenSaveSetting = regkeyScreenSaver.GetValue("ScreenSaveActive");
//Turn screen saver off
regkeyScreenSaver.SetValue("ScreenSaveActive", "0");
}
private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
// Reset screen saver to original setting
regkeyScreenSaver.SetValue("ScreenSaveActive", origScreenSaveSetting);
}