|
-
Mar 13th, 2001, 10:47 AM
#1
Thread Starter
Lively Member
anyone know how to intercept windows shutdown message and discard it b4 windows shuts down in other words prevent or delay windows shutdown?
Don't go away mad, just go away.
Bam-Bam
-
Mar 13th, 2001, 02:41 PM
#2
You cannot prevent this, because shutting down is related to the hardware of a computer.
-
Mar 14th, 2001, 03:21 PM
#3
Simple, it's really funny: Try this:
Create a new project, and in the Form1 code paste this:
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = True
End Sub
No API crap at all... No all you have to do is make the form invisible or something like that....
That's all! :-)
Rob
-
Mar 14th, 2001, 04:04 PM
#4
that prevents a Form from closing, but does not prevent windows from shutting off.
-
Mar 14th, 2001, 04:08 PM
#5
I know what you mean Megatron, but it actually does work on my PC (Win2000Pro) and on a server (WinNT 4 sp6a).
Have you tried it? Have a go and see for yourself!
P.s. You may have to compile to .exe and run that... I've tried it, and it really works!
Rob
-
Mar 14th, 2001, 11:31 PM
#6
I just pushed the power button and turn my computer off... As I said earlier, the power is controlled by hardware, thus you can't prevent it.
-
Mar 15th, 2001, 12:23 AM
#7
Not always true! 
When you have an ACPI power button (most modern pc's), Windows does control the shutdown! It's actually possible to hook the shutdown routine and prevent it from turning the pc off when you press the power button.
Most BIOS also have an option to turn the PC off when you jold POWER for 4 seconds, but that's also software and can be disabled.
You can always pull the plug of-course.
Gerco.
-
Mar 15th, 2001, 07:47 AM
#8
Lively Member
Eventually windows will say that the programs has stopped responding and it will ask you to close the program down, but also you can use InitiateSystemShutdown API call and use the EWX_FORCE flag to force windows to close all applications, so in the end, you will not be able to prevent windows from shuting down
-
Mar 15th, 2001, 09:27 AM
#9
Originally posted by Gerco
Most BIOS also have an option to turn the PC off when you jold POWER for 4 seconds, but that's also software and can be disabled.
Once you hold it for 5 seconds, the software doesn't have any control over it.
-
Mar 15th, 2001, 10:58 AM
#10
Untrue...
What is the thing that counts the 5 seconds? I have had situations in which my pc had crashed so badly that holding the power button for 10 seconds didn't do anything at all.
The software for the 5 second countdown is in the BIOS, but it's still software.
Gerco.
-
Mar 15th, 2001, 12:49 PM
#11
They cannot have everything supported by software. There has to be a way to shut down the computer without having to deal with software, because it's the software that does the crashing. They need a way for users to shut everything off, thus you cannot prevent a shut down.
I haven't heard of a machine that let's the software control the power after the 5 second deal.
-
Mar 15th, 2001, 01:00 PM
#12
Well in the BIOS you can choose to habe the power button switch the PC off instantly or after 4 seconds...
In theory, you can intercept the BIOS at the 4 second countdown point and abort it, unless that routine is in real ROM of-course...
But afaik, there is no program that allows you to do this. But I do have a 'power button override' option in my BIOS. And it doesn't matter if I hold down the Power button 5 seconds or a year, it won't shut down!
Gerco.
-
Mar 15th, 2001, 01:10 PM
#13
That's when you pull the plug 
Maybe it's the newer machines that have this feature, because I purchased my PC in 2000 and it does not allow me to intercept after 5 seconds.
-
Mar 15th, 2001, 01:22 PM
#14
I guess, I bought a new Mainboard 6 months ago and it does...
I can set it to Instant off, 4 second delay or disabled (override)
Gerco.
-
Mar 15th, 2001, 08:05 PM
#15
Fanatic Member
BamBam, you may want to use the UnloadMode parameter to assure that it is Windows that is trying to unload your app and not the user closing the app normally (i.e. clicking the X button)....
(note: you have to compile this program to an exe file to test this code)
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim retval As Integer
If UnloadMode = vbAppWindows Then
retval = MsgBox("Do you want To shut down Windows?", vbYesNo)
If retval = vbNo Then
Cancel = True
End If
End If
End Sub
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Mar 15th, 2001, 11:55 PM
#16
Won't windows say:
'This application is not responding to windows shutdown command, do you want to end now?'
I know WindowsNT does, but 98?
Gerco.
-
Mar 16th, 2001, 08:32 AM
#17
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|