Results 1 to 17 of 17

Thread: prevent windows shutdown

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Lost in the Mojave Desert
    Posts
    82
    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

  2. #2
    Guest
    You cannot prevent this, because shutting down is related to the hardware of a computer.

  3. #3
    Guest
    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

  4. #4
    Guest
    that prevents a Form from closing, but does not prevent windows from shutting off.

  5. #5
    Guest
    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

  6. #6
    Guest
    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.

  7. #7
    Guest
    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.

  8. #8
    Lively Member Ceri's Avatar
    Join Date
    Sep 2000
    Posts
    72
    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

  9. #9
    Guest
    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.

  10. #10
    Guest
    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.

  11. #11
    Guest
    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.

  12. #12
    Guest
    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.

  13. #13
    Guest
    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.

  14. #14
    Guest
    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.

  15. #15
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    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}

  16. #16
    Guest
    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.

  17. #17
    Guest
    Yes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width