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

x
?
Solved

Force Windows Reboot

Posted on 1998-07-15
20
Medium Priority
?
488 Views
Last Modified: 2013-11-20
I use the function ExitWindowsEx to reboot my computer. Everything works just fine except for the fact that if I try to force a reboot (EWX_FORCE | EWX_REBOOT )my system does shutdown but not reboot... it simply hangs up at a certain point after the shutdown is already done. What can I do ? (This only happens with Win95; with WinNT it works !!)
 
0
Comment
Question by:_punisher
[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
  • 10
  • 9
20 Comments
 
LVL 3

Expert Comment

by:shaig
ID: 1319189
Check if your system can reboot normally. this means through the shutdown menu.
if not succesful - the problem is in your 95 installation.
if succesful - i just tried to help :-)
0
 

Author Comment

by:_punisher
ID: 1319190
nop ... as I already mentioned ... it can reboot also with my program ! It only does not work with EWX_FORCE !
But thanx for trying to help ...
0
 
LVL 8

Accepted Solution

by:
trestan earned 600 total points
ID: 1319191
You can use the Win32 API ExitWindowsEx() on Windows NT to force a logoff. You accomplish this by combining the EWX_LOGOFF and EWX_FORCE flags. Unfortunately, this combination is not supported on Windows 95. Pls refer to MS online support for more information:
http://support.microsoft.com/support/kb/articles/q168/6/90.asp
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:_punisher
ID: 1319192
I get the following error when I try to compile the sourcecode I found on the Homepage you gave me. I use Visual C++ 5.0 and I have already experienced this problem before. I did not find it in Visual C++ 4.1.

Sorry ... I have a German Compiler!
It says: Conversion of parameter 1 from ... to ... not possible.

error C2664: 'EnumWindows' : Konvertierung des Parameters 1 von 'int (struct HWND__ *,unsigned long)' in 'int (__stdcall *)(struct HWND__ *,long)' nicht moeglich

What do I have to do ?
0
 
LVL 8

Expert Comment

by:trestan
ID: 1319193
Use EnumWindows((WNDENUMPROC)EnumWindowsProc, 0);  can correct the problem.

0
 

Author Comment

by:_punisher
ID: 1319194
That does not work either. Now I get the following message:

error C2440: 'type cast' : 'ueberladener Funktionstyp' kann nicht in 'int (__stdcall *)(struct HWND__ *,long)' konvertiert werden
Keine Funktion mit diesem Namen im Gueltigkeitsbereich stimmt mit dem Zieltyp ueberein

I hope you understand this compiler message because it is difficult to translate.
I`ll give it a try:
overloaded functiontype ... cannot be converted into ...

No function with this name in the valid range is identical to the destination type.

0
 
LVL 8

Expert Comment

by:trestan
ID: 1319195
This paragraph of file compiles fine on my machine (NT, VC5). You set the output setting to windows, right? WNDENUMPROC is the parameter type. Sould be no problem. Or would you like me to email my exe file?
0
 

Author Comment

by:_punisher
ID: 1319196
Thank you...but I need the sourcecode because it is a part of a larger program.
What do you mean by setting the output setting to windows ?
I use Win95 and have the ServicePack3 for VisualC++5.0.
I have this problem with callback functions in general (cf.TimerProc(SetTimer)). Is it Ok that in my SourceCode this CallbackFunction is part of a class:
CShutdownDlg::EnumWindowsProc ?
0
 
LVL 8

Expert Comment

by:trestan
ID: 1319197
I prefer you try the codes in a seperate project to see whether it is your desired. When the callback function is a member function of a class, it will be more complicated. Seems that it should be defined as static function. But I need to try it.
0
 

Author Comment

by:_punisher
ID: 1319198
Ok ... I´ll give it a try ... but if you have any news for me, please tell me !
0
 
LVL 8

Expert Comment

by:trestan
ID: 1319199
Define the member function as: static void CALLBACK.
0
 

Author Comment

by:_punisher
ID: 1319200
My compiler says that member functions must not be static. It does not change anything concerning this __stdcall. I also get this message when I do not use classes (as in the sample).
0
 
LVL 8

Expert Comment

by:trestan
ID: 1319201
I think there are some problems with your compiler. At least, no thing wrong when a function is declared as static. Compilation is really Ok after I add WNDENUMPROC. Can you try it on a NT? Nothing to do with the codes now. Change the project settings, link, in Project Options: subsystem:windows . However, this should not be the problem according to the error message.
0
 

Author Comment

by:_punisher
ID: 1319202
Somehow I need a solution for this problem ... would you mind if I reopen the question to other experts because I do not have enough points to ask a new question ...
0
 

Author Comment

by:_punisher
ID: 1319203
Ok ... I solved the problem ... thanks for your help !
0
 
LVL 8

Expert Comment

by:trestan
ID: 1319204
Would you mind tell me what is the problem? I am a little curious about what has happened. Thx.
0
 

Author Comment

by:_punisher
ID: 1319205
Yes of course. You suggested to declare the function as static void. That did not work. Instead I declared it like this:

static BOOL CALLBACK EnumWindowsProc(HWND hwnd,long lParam);

and in the implementation part I left it as it was. What I don`t understand is the fact that it did not work as described on the Homepage you gave me when I used a new Win32 application.
Well but I am happy that it works now.

But there is still another problem and perhaps you have an idea. I told you that I wanted to force a reboot and with your help it almost works. Unless there are no remote connections there is no problem but as soon as there are any, this stupid message "there are x computers conected to you" appears when I execute my program. Do you know the command to disconnect those computers before I shutdown ? It has to do the same that netwatch does (disconnect user). Please ... can you help ?
0
 
LVL 8

Expert Comment

by:trestan
ID: 1319206
So it is not a big error, just ignorance in some sense. Since you said your compiler does not even allow to declare a static function, I think it is mainly the compiler problem. I did not check the return type of the function. Anyway, it is a general ignorance in programming.
As of your question, actually I think it is worth to open a new question. I think you can use WNetOpenEnum to start WNetEnumResource to continue the enumeration of resources on the network and enumeration of currently connected resources. Then use WNetAddConnection to disconnect each of them. WNetCloseEnum to stop the enumeration. Hope it is helpful.
0
 
LVL 8

Expert Comment

by:trestan
ID: 1319207
Sorry, it should be WNetCancelConnection to disconnect a resource, not the contrarial WNetAddConnection.
0
 

Author Comment

by:_punisher
ID: 1319208
I managed to solve the problem of disconnecting all remote computers from mine by using NetSessionEnum and NetSessionDel but when I tried the whole program on another computer it did not work because some task where not closed and I had to terminate them. Actually I thaught this problem would not appear with your sourcecode since this was the main reason for me to ask this question.Do you have any ideas why the sourcecode you gave me does not close all the tasks ? I really do need code that closes all tasks because I am not on my computer when the program runs so I cannot manually kill any tasks. Please help me.

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

610 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