//=================================================== file = putSleep.c =====
//=  Program to put a Windows PC to sleep                                   =
//===========================================================================
//=  Notes:                                                                 =
//     1) See http://msdn.microsoft.com/en-us/library/aa373201(VS.85).aspx  =
//=-------------------------------------------------------------------------=
//   Build: cl putSleep.c powrprof.lib (will not build with bcc32)          =
//=-------------------------------------------------------------------------=
//=  Execute: putSleep                                                      =
//=-------------------------------------------------------------------------=
//=  Author: Ken Christensen                                                =
//=          University of South Florida                                    =
//=          WWW: http://www.csee.usf.edu/~christen                         =
//=          Email: christen@csee.usf.edu                                   =
//=-------------------------------------------------------------------------=
//=  History: KJC (08/02/08) - Genesis                                      =
//===========================================================================

//----- Include files -------------------------------------------------------
#include <stdio.h>        // Needed for printf() and feof()
#include <windows.h>      // Needed for Windows stuff
#include <powrprof.h>     // Needed for SetSuspendState()

//===========================================================================
//=  Main program                                                           =
//===========================================================================
int main()
{
  int retcode;            // Return code

  // Put the machine to sleep using SetSuspectState()
  printf("Put the machine to sleep... \n");
  retcode = SetSuspendState(FALSE, FALSE, FALSE);
  if (retcode == 0)
  {
    printf("*** ERROR - SetSuspectState() failed \n");
    return -1;
  }

  // This should execute when machine wakes-up
  printf("Machine is now awake! \n");

  // Return
  return(0);
}

