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

x
?
Solved

How to restart windows in VC++ without MFC?

Posted on 2001-08-15
10
Medium Priority
?
514 Views
Last Modified: 2013-12-03
  I am making a console application so "ExitWindowsEx" will no work, is there any other way. I want to run it on Win98.
   Restarting of windows is required to update the Autoexec.bat file which I have updated by my program. Is there any other way of setting the changes made in autoexec.bat without restarting the windows.

Thanks in advance,
Nitin
0
Comment
Question by:nitinkale
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 5

Accepted Solution

by:
robpitt earned 240 total points
ID: 6391536
ExitWindowEx(EWX_REBOOT,0) should work.

Does this return true or false?
If false what is the return value from GetLastError()?

Also have you read the remarks section of the MSDN documentation for ExitEindowsEx, there it details what you need to do to make it work on NT. Note it also says:
"Windows 95/98/Me: ExitWindowEx does not work from a console application"

0
 
LVL 20

Expert Comment

by:Madshi
ID: 6391565
Please post your code - and the OS. In winNT/2k/XP you need enough privileges to successfully call ExitWindowsEx. What does GetLastError say after you called it?

Regards, Madshi.
0
 
LVL 32

Expert Comment

by:jhance
ID: 6392117
>>>have tried the API "ExitWindowsEx" but it is not working in VC


Please define "not working".  The ExitWindowsEx API is KNOWN TO BE GOOD and it is used by 1000s of programs every day.  If you call it correctly, it will work.

Is this Windows 9x or NT/2000?  On NT/2000 your calling process MUST have the SE_SHUTDOWN_NAME privilege.  Your non-administrator account may not have this by default.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 32

Expert Comment

by:jhance
ID: 6392118
By the way, if ExitWindowsEx() fails, it does return an error code.  Call GetLastError() and report the reason.
0
 
LVL 5

Expert Comment

by:robpitt
ID: 6393684
P.S.
Of course it might be failing because another app cancels the request (see WM_QUERYENDSESSION). To bypass this you would need to use the EWX_FORCE flag.
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6396927
all - according to the MS documentation ExitWindowsEx does not work from a console app on 95/98/Me and nitinkale has expressed a wish to do this from a console app on 98. If the documentaion is wrong please don't have a go at nitinkale but explaing why it is wrong
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6396960
nitinkale - you can turn you console app quite easily into a WIN32 app - use the wizards in visual studio and create a simple app - then copy your code from main() into WinMain() and away you go - then you can use ExitWindowsEx
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

782 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