Results 1 to 12 of 12

Thread: keeping windows from shutting down

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Location
    Texas
    Posts
    313

    Question

    Is their a way to disable windows from being able to shut down? Granted you could just hit the power switch. But I have 2 computers networked, and i use them both and at times people shut off the other one while I am useing it. I want to make it so I can tell windows not to let it shut down. So the only way you could shut down the comp would be by hitting the power switch.

  2. #2
    Guest
    ummmmm....
    you could subclass so the user can not click the "**** down" on the start menu, and you would also have to subclass so when ctrl-alt-del is hit twice it wouldnt do anything,
    this would require a DLL in made in C++ though, and I dont really know how to do any of it... I am just giving you ideas

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I haven't used it but it should do the trick i think
    Code:
    Declare Function AbortSystemShutdown Lib "advapi32.dll" Alias "AbortSystemShutdownA" (ByVal lpMachineName As String) As Long
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Unhappy Nah...

    MSDN says:
    The InitiateSystemShutdown function displays a dialog box that notifies the user that the system is shutting down.
    During the InitiateSystemShutdown time-out period, the AbortSystemShutdown function can prevent the system from shutting down.
    Also, it's only for NT, and, your program must have a certain privilege (from what I remember, setting privileges on NT is more trouble than it's worth).
    Even hooks (like denniswrenn suggested) aren't "allowed" to disable shutting Windows down.
    Besides, are you sure you don't want Windows to ever shut down?

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    But i'm sure there is a way, for instance if you cancel notepad with typed text in it, shutdown will automatically abort At least you could shell notepad, send a little text, alt F4 and then press cancel
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Try it the "notepad method". (Not sure if it will work)
    Create a form with Visible = False and add this code.
    Code:
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Cancel = True
    End Sub

  7. #7
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Works great, Yonatan.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    It works! I can't believe it
    hmm, ok anyway ctrl-alt-del can be disabled also:
    Code:
    Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
    
    SystemParametersInfo 97, bDisabled, CStr(1), 0
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Wow. The last words I expected to see in reply are "it works great". I can't believe it!
    The code that disables Ctrl-Alt-Del does so by tricking the system to think a screen saver is running.
    Because of this, also other key combinations like Alt-Tab and Ctrl-Esc will be disabled.

    P.S.
    oetje: Thank you VERY FREAKING MUCH for spelling my name correctly.

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    WoW! WoW! and WOW again
    Sorry i didn't notice that it actually was Yonatan , welcome back!

    Yep, you are disbled from everything except to press that power or reset button
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  11. #11
    Guest
    How is vbAppWindows used?

    unloadmode - A value or constant indicating the cause of the QueryUnload event, as described in Return Values.

    vbAppWindows - 2 - The current Microsoft Windows operating environment session is ending.


    http://forums.vb-world.net/showthrea...threadid=21294

    Code:
        If UnloadMode = vbAppWindows Then
            Shell "C:\yourapppath\yourapp.exe", vbNormalFocus
        End If
    End Sub
    You Shell a program upon shutting down, but how would you stop Windows? Would it be something like:

    Code:
    If UnloadMode = vbAppWindows Then Cancel = True

  12. #12
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Put it all together, in a huge mess, and it somehow works.
    Code:
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        If UnloadMode = vbAppWindows Then
            Call Shell("C:\YourAppPath\YourApp.Exe", vbNormalFocus)
            Cancel = True
        End If
    End Sub

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