Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reboot from MFC application

Posted on 2007-04-02
8
Medium Priority
?
1,538 Views
Last Modified: 2013-11-20
Hi,

Is there any function in MFC that will reboot(soft)  the work station while exiting from a MFC application.

The requirement is if the user press a button it will exit the application and it will reboot the
computer also.  If it's possible is any source code available?

I am using VC++ 6.

Thanks
0
Comment
Question by:pbsmbc
[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
  • 3
  • 3
  • 2
8 Comments
 
LVL 9

Expert Comment

by:Priyesh
ID: 18840049
void CMyView::OnBnClicked()
{
   //save all your work
  ExitWindowsEx(EWX_REBOOT, 0) ;
}
0
 

Author Comment

by:pbsmbc
ID: 18840769
Does the user (who is using the application) need to have administrative privilage to reboot?
0
 
LVL 9

Expert Comment

by:Priyesh
ID: 18841471
Yes, please take a look at this link from MSDN for some sample code.

http://msdn2.microsoft.com/en-us/library/aa376871.aspx
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 86

Accepted Solution

by:
jkr earned 1500 total points
ID: 18843885
>>Does the user (who is using the application) need to have administrative
>>privilage to reboot?

No. Just the SE_SHUTDOWN_NAME when using

InitiateSystemShutdown(NULL,NULL,0,TRUE,TRUE);

See also http://msdn2.microsoft.com/en-us/library/aa376883.aspx ("System Shutdown Functions") and http://msdn2.microsoft.com/en-us/library/aa376881.aspx ("Shutting Down")
0
 
LVL 9

Expert Comment

by:Priyesh
ID: 18845610
Sorry for answering Yes to your "is administrative privileges required " question. jkr above is right and that's what the link i qouted with the comment indicates as well.
0
 

Author Comment

by:pbsmbc
ID: 18847130
Thanks jkr.
What is the difference between InitiateSystemShutdown and exitwindowex?
0
 
LVL 86

Expert Comment

by:jkr
ID: 18848508
Both will have the same effect, yet 'InitiateSystemShutdown()' is the more NT-like solution that is safe to follow up the path over XP to it's successors.
0
 

Author Comment

by:pbsmbc
ID: 18878898
Our application is running on both XP and NT.  
So is InitiateSystemShutdown better choice?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 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