You can simply disable the task manager thru editing the windows registry.
I already tried to see the result and it does really did a perfect solution. Not even a Ctrl-Shft-Esc can open the task manager. I tried it on a Windows XP, well.. I dont know if it works on some OS. You can include a command and function to your code modifying the windows registry on the following address..
That code was included in the orginal example, but is not as good.
You need certain rights, to set that in the registry.
It displays a messagebox, telling you that the task manager is disabled by your administrator.
This steals focus, and makes a nasty "bomp" sound.
However here is a full solution using the registry:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TTn, I see in your code where this is suppose to stop Alt F4. Most of it works so far but this doesn't work for me. I hit Alt and F4 and it shuts my program down. Any ideas?
JXDOS, Do you not see where I mention that I SEE in his code where it blocks Alt F4? Which means I have read this entire thread. So please don't waste my time asking me to read a thread, I don't post unless I read the thread. What I am saying is that all of it works except for that one on my PC and was asking if he had any idea why or what could cause that.
Hmm.. That's weird. It works great on mine. I created a form the size of my screen, made it always on top and hide my taskbar and put that code in there. I d/l a list of shortcut keys and it blocked them all. I ended up having to reboot to get back out of it because I forgot to add a exit button.
how do you log onto windows XP? Do you use that weclome screen? or do you use the traditional login method where user name and password has to be typed?
Are you using XP Pro or XP Home?
Often times these types of differences will change the behavior of ctrl+alt+delete.
For example, on XP home when you ctrl+alt+delete you simply get the taskmanager.
well, as you can see from my screen shot, it doesn't close mine.
I'm not trying to fool anyone here... I would be more than happy to see real ctrl+alt+delete blocking code, but this code doesn't do ANYTHING that I can see when I run it. I compiled and ran the exe from windows in release mode just as you said.
That is kinda weird, but as you see there's no problem detecting a Ctrl Alt Delete combo.
It's not a problem to kill the task manager quickly.
kleinma, it does seem like you're making it out to be some mythical legend perhaps to dissuade people from using it. No big deal either way.
The task manager kill procedure, is on a timeout.
Set it a little higher.
I believe you can also create, and/or use this registry setting for that.
HKEY_CURRENT_USER > Control Panel > Desktop > LowLevelHooksTimeout
no, I am just saying that I haven't seen any VB code to actually do it and have it work on my system.
If you can give me code to do it fine, but now its sounding a bit silly, all sorts of registry hacks and such to try to make it work? I'm not going to go screwing around with my system to try to get it to work, when with the default settings my system is using now, it doesn't work.
Maybe it works on some systems, but it obviously isn't fool proof...
no, I am just saying that I haven't seen any VB code to actually do it and have it work on my system.
If you can give me code to do it fine, but now its sounding a bit silly, all sorts of registry hacks and such to try to make it work? I'm not going to go screwing around with my system to try to get it to work, when with the default settings my system is using now, it doesn't work.
Maybe it works on some systems, but it obviously isn't fool proof...
Maybe it works on most systems, especially those where one wants to have this function.
It's not a registry hack to Set it a little higher.
An advanced version would sync up to the registry setting.
Besides, you've already commited yourself here:
I guarantee that any code you might put in your app to get around ctrl+alt+delete I could easily bypass.
If you're still game, we can do this offline sometime.
sure if you update the code to the "advanced" version, I will be happy to try it again on my system, as well as Vista if you like.
I am not bashing your code, or telling people not to use it. All I am saying is it doesn't work when I try it. I am not going to jump through hoops to figure out why, simply because I don't really care why it doesn't work.
If it did work, I would then try to circumvent it, and see if that was possible.
If I could not find a way around it, then I would concede and be more than happy to tell you I can't bypass it.
Until then I am just stating for the record that this doesn't work on my XP Pro machine, I am just saying it in case someone comes along and thinks they could copy/paste this code into their app and the end user won't be able to hit ctrl+alt+delete
If you are genuinely curious, try adding a little more time in the KillTaskManager loop. No fuss, no hoops to go through.
I'd be willing to withdraw questionable, or missusable submissions, but the codeguru seems to have no problem with it.
I am curious if this works on Vista, but I'd trust my own objective tests for that.
It may be easier to circumvent the code if you've gotten a chance to look at it up close. But what if you didn't?
I could circumvent it myself, in about five different ways back and forth.
I'm not sure if there is an end to it...
However there is no subjective guarantee either way, as you put it.
Did you make any changes to the code, or your system before trying it?
It looks a little like you have.
Until then I am just stating for the record that this doesn't work on my XP Pro machine, I am just saying it in case someone comes along and thinks they could copy/paste this code into their app and the end user won't be able to hit ctrl+alt+delete
For the record this code works on everyone elses PC except yours. You are the first person, of at least a dozen others.
Re: How to swap keyboard keys, ie press A but send Z
Originally Posted by TTn
'Here is an example of how to SwapKeys.
'It's somewhat like SwapMouseButtons, but only for the keyboard.
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
HookKeyboard()
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
UnhookKeyboard()
End Sub
Public Function IsHooked(ByRef Hookstruct As KBDLLHOOKSTRUCT) As Boolean
On Error Resume Next
If Hookstruct.flags <> 128 Then 'Do this on key down only. the flag for key up is 0.
If Hookstruct.vkCode = Keys.A Then 'If a key is pressed
apikeybd_event(Keys.Z, 0, 0, 0) 'press any key. (z in this example)
Return True
End If
'Repeat this skeleton for any key, or combo!!!
'If Hookstruct.vkCode = Keys.A Then
' apikeybd_event(Keys.Z, 0, 0, 0)
' Return True
'End If
End If
Return False
End Function
Public Structure KBDLLHOOKSTRUCT
Public vkCode, scanCode, flags, time, dwExtraInfo As Int32
End Structure
Public Delegate Function KeyboardHookDelegate(ByVal Code As Int32, ByVal wParam As Int32, ByRef lParam As KBDLLHOOKSTRUCT) As Int32
<System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.FunctionPtr)> Private callback As KeyboardHookDelegate
Public KeyboardHandle As Int32
Const HC_ACTION As Int32 = 0
Const WH_KEYBOARD_LL As Int32 = 13
Const VK_CONTROL As Int32 = 17
Public Declare Function apiSetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Int32, ByVal lpfn As KeyboardHookDelegate, ByVal hmod As Int32, ByVal dwThreadId As Int32) As Int32
Public Declare Function apiCallNextHookEx Lib "user32" Alias "CallNextHookEx" (ByVal hHook As Int32, ByVal nCode As Int32, ByVal wParam As Int32, ByVal lParam As KBDLLHOOKSTRUCT) As Int32
Public Declare Function apiUnhookWindowsHookEx Lib "user32" Alias "UnhookWindowsHookEx" (ByVal hHook As Int32) As Int32
Public Declare Sub apikeybd_event Lib "user32.dll" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32)
Public Sub HookKeyboard()
callback = New KeyboardHookDelegate(AddressOf KeyboardCallback)
KeyboardHandle = apiSetWindowsHookEx(WH_KEYBOARD_LL, callback, System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.[Assembly].GetExecutingAssembly.GetModules()(0)).ToInt32, 0)
End Sub
Public Sub UnhookKeyboard()
If KeyboardHandle <> 0 Then apiUnhookWindowsHookEx(KeyboardHandle)
End Sub
Public Function KeyboardCallback(ByVal Code As Int32, ByVal wParam As Int32, ByRef lParam As KBDLLHOOKSTRUCT) As Int32
If Code = HC_ACTION AndAlso IsHooked(lParam) = True Then Return 1
Return apiCallNextHookEx(KeyboardHandle, Code, wParam, lParam)
End Function
Hi TTn,
Is this VB6, as i am getting lots of RED lines while pasting this code in VB6....