Solved

Reboot from MFC application

Posted on 2007-04-02
8
1,493 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 86

Accepted Solution

by:
jkr earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 136
fizzArray2 challenge 1 79
Window placement 17 82
wordmultiple challenge 12 132
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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