Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Shutting down Windows XP

Posted on 2004-09-05
9
Medium Priority
?
226 Views
Last Modified: 2010-04-01
How do I programmatically shut down Windows Xp properly?
0
Comment
Question by:bradsoblesky
6 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 672 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 664 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 664 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

879 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