Solved

Shutting down Windows XP

Posted on 2004-09-05
9
214 Views
Last Modified: 2010-04-01
How do I programmatically shut down Windows Xp properly?
0
Comment
Question by:bradsoblesky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 168 total points
ID: 11984562
       HANDLE hToken;
        TOKEN_PRIVILEGES tkp;
 
        // Get a token for this process.
        if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
        {
            // Get the LUID for the shutdown privilege.
            LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
 
            tkp.PrivilegeCount = 1;  // one privilege to set    
            tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
 
            // Get the shutdown privilege for this process.
            AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
 
 
            ExitWindowsEx(EWX_POWEROFF | EWX_FORCE, 0);
        }
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 166 total points
ID: 11985077
I'd prefer

InitiateSystemShutdown ( NULL, NULL, 5, TRUE, FALSE);

over 'ExitWindowsEx()', but that's just my personal preference
0
 

Author Comment

by:bradsoblesky
ID: 11995449
seem like neither of these suggestions are working.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Assisted Solution

by:Fahdmurtaza
Fahdmurtaza earned 166 total points
ID: 11995838
Well I think what you need is the free code at....

http://www.codeproject.com/useritems/standstillpcasp.asp

All you have to do is that just make  free account over there. I have been a member ovr there for last three years and I learned alot..

Regards
Fahd Murtaza
0
 
LVL 6

Expert Comment

by:Fahdmurtaza
ID: 12305192
I think you are right Tincho. He hasn't responded and now after this comment being added he should respond.
Regards,
Fahd Murtaza
0
 
LVL 6

Expert Comment

by:Fahdmurtaza
ID: 12562563
Ok man just do it as it may be useful for someon else at ee.
Regards,
Fahd Murtaza
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question