SetSystemPowerState question

This is a discussion on SetSystemPowerState question within the Windows Programming forums, part of the Platform Specific Boards category; Does it only suspend the system or i can use it for reboot also? Which function do they use installation ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    69

    SetSystemPowerState question

    Does it only suspend the system or i can use it for reboot also?

    Which function do they use installation programs for rebooting the system ?

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Use ExitWindowsEx or InitiateSystemShutdown. You will need to enable the SE_SHUTDOWN_NAME privilege. You can use my EnableProcessPrivilege function. Rebooting should always be optional.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    69
    Quote Originally Posted by anonytmouse
    Use ExitWindowsEx or InitiateSystemShutdown. You will need to enable the SE_SHUTDOWN_NAME privilege. You can use my EnableProcessPrivilege function. Rebooting should always be optional.

    Good Work! But i want also my process to be restored after reboot,and the context to be the same as it was before reboot...is it possible?
    Setup programs do it
    Last edited by Lionel; 05-29-2005 at 02:49 PM.

  4. #4
    Registered User
    Join Date
    Mar 2005
    Posts
    69
    ??

    How do setup programs reboot the system and automatically restore their execution just where they were before rebooting??

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You can have your program start after the reboot by adding it to the RunOnce registry key. Context will not be restored automatically but you can use a command line option to indicate to your program to start at a specific point.

    Example:
    Code:
    // Command line: C:\\mypath\\myprogram.exe /afterreboot
    
    // At program start:
    if (strstr(lpCmdLine, "/afterreboot") != NULL)
    {
       // goto to after reboot stage
    }
    else
    {
       // goto beginning
    }

  6. #6
    Registered User
    Join Date
    Mar 2005
    Posts
    69

    Thumbs up


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21