Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Disable Ctrl+Alt+Del in Windows XP and 2000


Disable Ctrl+Alt+Del in Windows XP and 2000

Author
Message
neilDiamond
neilDiamond
Forum God
Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)

Group: Forum Members
Posts: 3, Visits: 1
Hi! Anyone know's how to disable windows CTRL+ALT+DEL, ALT+F4, ALT+TAB, ALT+ESC in windows XP and 2000? I got hold of some API procedures but it only works with win 95 and win 98 only. Please help anyone,if you know of any code or URL where I can download the code. Thanks in advance.


Simplicity in Complexity
Milo
Milo
Forum God
Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)

Group: Forum Members
Posts: 334, Visits: 16

You will need to use the virtual key stuff for this, you can use this for the ctrl+alt+del if you want or there is a registry entry you can use if you want any here is the code:

Option Explicit

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public Const HC_ACTION = 0
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_SYSKEYDOWN = &H104
Public Const WM_SYSKEYUP = &H105
Public Const VK_TAB = &H9
Public Const VK_CONTROL = &H11
Public Const VK_ESCAPE = &H1B
Public Const VK_STARTKEY = &H5B


Public Const WH_KEYBOARD_LL = 13
Public Const LLKHF_ALTDOWN = &H20

Public Type KBDLLHOOKSTRUCT
    vkCode As Long
    scanCode As Long
    flags As Long
    time As Long
    dwExtraInfo As Long
End Type

Dim p As KBDLLHOOKSTRUCT

Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
   Dim fEatKeystroke As Boolean
  
   If (nCode = HC_ACTION) Then
      If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Or wParam = WM_KEYUP Or wParam = WM_SYSKEYUP Then
         CopyMemory p, ByVal lParam, Len(p)
         fEatKeystroke = _
            ((p.vkCode = VK_TAB) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
            ((p.vkCode = VK_ESCAPE) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
            ((p.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0)) Or _
            p.vkCode = VK_STARTKEY
           
        End If
    End If
   
    If fEatKeystroke Then
        LowLevelKeyboardProc = -1
    Else
        LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
    End If
End Function

 

if you put this in a module and call this from the form

    hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0)

and this in the unload or when you exit the program:

        UnhookWindowsHookEx hhkLowLevelKybd
    hhkLowLevelKybd = 0

this will stop alt+esc,ctrl+esc,alt+tab,startkey.  to stop alt+F4 you want to put this in the form_unload:

    Cancel = True

as for ctrl+alt+del you want to edit the code above with the relevant vkkeys or edit this registry entry:

HKCU\software\microsoft\windows\currentversion\policies\system\DisableTaskMgr

to a 1.  Remember to change it back to 0 when you exit the program!!!

Hope this helps!



Milo

Milo!


neilDiamond
neilDiamond
Forum God
Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)Forum God (793 reputation)

Group: Forum Members
Posts: 3, Visits: 1
Hi!

Thank you very much for the solution, I have tried already the registry editing before and it kind of work a little by disabling the task manager but not necessarily CTRL+ALT+DEL, but it really helps anyway coz my main objective is not to let the users have a hand on the task manager anyway. But nevertheless, I will try the long solution you gave, hehehe. I will let you know what ever happens. Thanks a lot.

Neil


Simplicity in Complexity
TrickyRic
TrickyRic
Forum God
Forum God (91K reputation)Forum God (91K reputation)Forum God (91K reputation)Forum God (91K reputation)Forum God (91K reputation)Forum God (91K reputation)Forum God (91K reputation)Forum God (91K reputation)Forum God (91K reputation)

Group: Forum Members
Posts: 711, Visits: 6
nice code milo.


it kind of work a little by disabling the task manager but not necessarily CTRL+ALT+DEL


...this is because ctrl+alt+del sends an ascii value which is a direct cpu interupt and has a far higher priorty than windows, or even dos. windows can only listen to this value, and execute an event of its own when it hears it (ie: launch task manager). by editing a registry value as milo has shown, windows knows not to execute this event, but is still too low a priority to physically disable the interupt.




API Guide - VB/MySQL - W3Schools - WinsockVB

Milo
Milo
Forum God
Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)Forum God (24K reputation)

Group: Forum Members
Posts: 334, Visits: 16

oops 4got a main thing...:

 

do this in the form declarations:

Dim hhkLowLevelKybd as Long



Milo

Milo!


kwandobe
kwandobe
Forum God
Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)

Group: Forum Members
Posts: 22, Visits: 4

I know im having a brain freeze if I have to ask this:

((p.vkCode = VK_DELETE) And ((p.FLAGS And LLKHF_ALTDOWN) <> 0) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0)) Or _

this is not correct no?



-kwandobe


John_C
John_C
Forum God
Forum God (575 reputation)Forum God (575 reputation)Forum God (575 reputation)Forum God (575 reputation)Forum God (575 reputation)Forum God (575 reputation)Forum God (575 reputation)Forum God (575 reputation)Forum God (575 reputation)

Group: Forum Members
Posts: 3, Visits: 1
Check out http://www.meliorasoft.com/kits/
kwandobe
kwandobe
Forum God
Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)

Group: Forum Members
Posts: 22, Visits: 4
Sorry John, but that didn't get me anywhere

-kwandobe


Smeg40k
Smeg40k
Forum God
Forum God (413 reputation)Forum God (413 reputation)Forum God (413 reputation)Forum God (413 reputation)Forum God (413 reputation)Forum God (413 reputation)Forum God (413 reputation)Forum God (413 reputation)Forum God (413 reputation)

Group: Forum Members
Posts: 1, Visits: 1
I realise this is an old post but i found it after doing a google search and was wondering if anyone could help. I have got the code working sort of. It will disable Alt-Tab windows key etc, but it does not do CTRL - ALT - DEL and CTRL  - BREAK which if someone could get that working i would be most greatful
Electrical
Electrical
Forum God
Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)

Group: Forum Members
Posts: 30, Visits: 5
Another simple way by one line of code to disable CTRL+ALT+DELETE

open"C:\Windows\system32\taskmgr.exe" for random lock read as #1

but don't gorget to
cloase #1 when u exit

Eng. Tamir Darweesh
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search