CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Disabling Ctrl Alt Del keys

    A nice funtion to disable all the Ctrl + Alt + Del, Ctrl + Esc keys to prevent the user from exiting the form - you can also set the form's Border Style property to 0 - None.

    Here's the code.

    First declare the API function.
    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 'API Function to disable keys



    Then the sub (Also in General Declarations)
    Sub DisableCtrlAltDel(bDisabled as Boolean)

    ' Disables Control Alt Delete Breaking
    'as well as Ctrl-Escape

    Dim X as Long
    X = SystemParametersInfo(97, bDisabled, CStr(1), 0)

    End Sub

    'to disable CtrlAltDel do a call as such...
    'Call DisableCtrlAltDel(true), '
    'to re-enable use false instead of true in the call.



    To call the function just do like this:
    Call DisableCtrlAltDel(false) 'can use true as well



    Remeber to re-enable it when the program exits!

    Peace!


    F. T. W.

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    3

    Re: Disabling Ctrl Alt Del keys

    WOW
    That's brilliant coding.

    However, it does not appear to work on Windows 2000 and I was wondering if you knew why it did not work, and how I can make it work.

    Thanks

    Bye

    WWWhy not visit James Griffiths' web site @ www.jamesgriff.co.uk

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Disabling Ctrl Alt Del keys

    I haven't tested it at all on Windows 2000. Sorry... I'll do some research, and when I find the answer I'll let you know, because now I want to know why it doesn't work on Win2000 as well.
    Thanx for letting me know!
    Hannes


    F. T. W.

  4. #4
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Disabling Ctrl Alt Del keys

    Somebody some time ago asked how Print Screen could be disabled. Maybe you have the solution.


  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Disabling printscreen

    Joust a thougt:
    If you are able to intercept the printscreen keystroke, you can clear the clipboard object....

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  6. #6
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Disabling Ctrl Alt Del keys

    W2000 is based on NT platform. You cannot block alt+ctrl+delete on Windows NT. Even using a low-level keyboard hook doesn't work.
    NT traps this key combination before the event handler gets it and automatically handles it. The only way
    that you could do anything about it would be to write your own dll which receives this event from the
    O/S however this is an extremely complex task.


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  7. #7
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Disabling Ctrl Alt Del keys

    This works by convincing windows that a screensaver is running.
    In Win9x, it is the responsibility of the screensaver to validate the password so in response to getting the "Screen Saver Active" message, windows 9x disables the CTRL+ALT+DEL hotkey combination.
    Because of the enourmous potential for writing a malicious screensaver application this functionality was removed from WinNT/Win2k and it is now the responsibility of the OS to handle locking/unlocking a machine.

    Note that you should use the constant value:

    private Const SPI_SCREENSAVERRUNNING = 97



    to make this code more readable.

    For a full list of system parameter info constants, see http://www.merrioncomputing.com/Even...etersInfo.html

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

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

Featured