Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Friday, February 11, 2011

How to Hibernate from .NET Apps and How to enable Hibernate in Windows XP

The usage of Computer desktop or laptop is increased all around the world phenomenally. This link gives you the picture on how power consumption is for various devices we use daily. to reduce the power consumption Hibernate is one of the best way provided by default in Windows Vista or Windows 7. Hibernate feature enables you to close the machine without closing your applications, that means the applications will be restored as they were once we restart the machine. Hibernate feature is not enabled in Windows XP by default. I’ve seen many people that they run (do not switch off) the machines months and months as they do not want to close the windows or applications running in Windows XP. below are the steps to enable Hibernate in Windows XP.

  1. Right click on Desktop.
  2. Click on properties.
  3. Go to screen save tab.
  4. Click on power button
  5. Select Hibernate tab
  6. Check the checkbox “Enabled Hibernate”
  7. Apply the settings.


Now when you try to shutdown, “Shut down windows” dialog shows “Hibernate” options. Now you can safely close the machine without closing your applications or windows as they will be restored once you on the machine.


Some time you might want to provide this future programmatically for the applications you develop for windows. Generally you might want to provide this option in windows applications where process needs huge time. Download managers are the one of the best example. below is the code to do a Hibernate from the .NET code.

using System.Windows.Forms;

namespace CodeKicks.WinApp.Machine
public static class MyMachineHelper
public static void DoHibernate()
//Application.SetSuspendState(PowerState.Suspend, true, false);
Application.SetSuspendState(PowerState.Hibernate, true, false);

Post a Comment