• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Reboot without verification

Hi ! How can I reboot win95/98 computer without verification when documents are opened ???
0
ItsMe
Asked:
ItsMe
  • 6
  • 3
1 Solution
 
MadshiCommented:
Hi again...   :-)

Use this one:

  ExitWindowsEx(EWX_REBOOT or EWX_FORCE, 0);

Regards, Madshi.
0
 
ItsMeAuthor Commented:
really with or between, or one of 'em ?
0
 
ItsMeAuthor Commented:
I've already tryed with EWX_FORCE or Reboot but it doesn't work. 1. I have to call it twice to get a result. EWX_FORCE makes windows crashing and reboot seem to send wm_endsession to apps. so they're asking for "save document ?"

regards
ItsMe
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
ItsMeAuthor Commented:
I've tried your solution. I'm surprised, that the compiler accepts the or :-). *But* Windoof hangs up at the screen "windows wird heruntergefahren".

regards
ItsMe
0
 
simonetCommented:
>"windows wird heruntergefahren".

Translating that would really help non-German folks around here!

Alex
0
 
ItsMeAuthor Commented:
Oh, sorry: "the computer shuts down" :-) (It should shut down)
0
 
MadshiCommented:
Hi ItsMe, those EWX_* constants are simply 32bit ordinals, that means you can use "or" and "and" and even "xor" - if you like...   :-)

Well, strange, that your compi hangs during shutdown, mine does not!

If it all doesn't help you could go the hard way and terminate all running processes, then do a "normal" shutdown. But then you must know how to enumerate all running processes. Which Delphi-version do you have? Sorry, I have to ask again, though probably you've already told me that 10 times...   :-)

Regards, Madshi.
0
 
ItsMeAuthor Commented:
I've got Delphi 4.0. You mean I should send WM_Destroy to
all windows ? I'm interested in getting a list of all windows, this must be possible with FIndNext or something like that ? I don't know, perhaps - no sure - you know ?
But I think if only my comp hangs I will use  it in my app as is. If a comp hangs its not my problem :-)

regards
ItsMe
0
 
MadshiCommented:
You should test your program on other PCs. If it only hangs at your PC - leave it as it is. Otherwise do this:

(1) Download the unit "enumStuff.pas" from my homepage. Then do something like this:

procedure TerminateAllProcesses;
var pl : TProcessList;
    i1 : integer;
    c1 : cardinal;
begin
  pl:=GetProcessList;
  for i1:=0 to high(pl) do
    if (pl[i1].id<>GetCurrentProcessID) and (CompareText('kernel32.dll',ExtractFileName(pl[i1]))<>0) then begin
      c1:=OpenProcess(PROCESS_ALL_ACCESS,false,pl[i1].id);
      TerminateProcess(c1,0);
      CloseHandle(c1);
    end;
end;

But this is quite hard stuff! So please save all files before you do this...   :-)
Afterwards the EnumWindowsEx should work at once. You don't even need the force flag anymore.

Sending a WM_DESTROY to all windows won't work. Though, if you don't want to use such a big unit like mine, you can enumerate all windows (EnumWindows), then call GetWindowThreadProcessID for each window to get the processID of the process to which each window belongs. Then you can open the process and terminate it like I did in my little loop above. But note, that there are some applications that don't have windows at all. You can stop those apps only by using something like my unit.

Regards, Madshi.
0
 
ItsMeAuthor Commented:
Thanks, I'll try your "or" solution. I think it work on other machines.

regards
ItsMe
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now