CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    11

    How could I shutdown a computer in my VC++ program?

    I want my program could shutdown computer, I know how to suspend it, but How can I shutdown it?
    Thanks.


  2. #2
    Guest

    Re: How could I shutdown a computer in my VC++ program?

    ExitWindowsEx ( EXW_SHUTDOWN, 0 );

    will start a shutdown but will prompt the user whether to close any active applications - this gives the user the chance to cancel the shutdown.

    ExitWindowsEx ( EXW_SHUTDOWN|EXW_FORCE, 0 );

    does a shutdown, killing any active applications.


  3. #3
    Join Date
    Apr 1999
    Location
    Portland, OR, USA
    Posts
    18

    Re: How could I shutdown a computer in my VC++ program?

    There is an additional snag if you're running on Windows NT. You have to set up the application's process token with permissions to allow you to shut down the PC.

    The functions you'll need to look at are:
    OpenProcessToken()
    GetTokenInformation()
    LookupPrivilegeValue()
    AdjustTokenPrivileges()

    If you're running on Windows 95/98, you don't have to worry about this.

    Good luck!

    Valerie Bradley
    http://www.synthcom.com/~val
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured