Solved

Shutting down Windows XP

Posted on 2004-09-05
9
185 Views
Last Modified: 2010-04-01
How do I programmatically shut down Windows Xp properly?
0
Comment
Question by:bradsoblesky
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now