VB-Disable Ctrl Alt Del in XP, Hide TaskBar, Disable Windows keys
Ok, I'm just packin this stuff together =O
The only thing I haven't seen on this forum is about disabling ctrl alt delete.
--Ctrl Alt Del Here is a Link to a great article.
At first you might think it isn't possible with vb6 judging by its title.
But give things a chance ^_^ I will leave you in suspense by saying no more.
If anything, you'll be disappointed, but relieved that there is a way to accomplish it.
If you don't want to use any of the methods listed in the article,
I saw that someone posted their idea and it killed (deleted)
taskmgr.exe on a timer- because windows remakes if you delete
it from the system32 dir. A decent timer interval value is 100-500 ms.
Make sure you put On Error Resume Next in the sub that kills taskmgr.exe.
Sometimes I got a path/file access error, probably from crammed timer events.
--Hide TaskBar(only)
This will remove the taskbar graphic from the users screen.
It will not be displayed until you show it.
If the user presses the
Windows key, it will show the StartMenu,
but this can be fixed, as shown in the next example.
Search msdn or AllApi.net for the API calls used and not defined.
--Disabling Keys such as Windows, Alt+tab, Alt+Esc, Ctrl+Esc, W+L,W+R,W+F,..etc.
I used the low level hook from merrion_computing's eventvb.dll.
It seems to work just as good as a soldering iron, except that
you can actually change it back just by running the unhook code ='(
I didn't use modules as much as I could have because I was
getting the shortcut keys received by windows and processed..
(rarely, but still happened), and I thought less code jumps might eliminate the problem.
It could have been because I was running from vb.
With an executable, I can't get anything to pass through,
no matter how fast I press.
This code could be changed somewhat, but I just did what I needed to do to get it to work fast.
Download the dll in the attachment
-reg it on your system by typing in run "regsvr32 " & [filename]
-open up a project and add the reference named "MCL Event VB Release _ "
Put in general declarations area:
VB Code:
Private Declare Function MessageBeep Lib "user32" (ByVal wType As Long) As Long
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private WithEvents apiLink As EventVB.APIFunctions
Private WithEvents hook As EventVB.ApiSystemHook
Private Const vbKeyLWin As Integer = 91
Private Const vbKeyRWin As Integer = 92
Private Const vbKeyLCtrl As Integer = 162
Private Const vbKeyRCtrl As Integer = 163
And then for the events:
VB Code:
Private Sub Form_Load()
Set apiLink = New EventVB.APIFunctions
Set hook = apiLink.System.Hooks
hook.StartHook WH_KEYBOARD_LL, HOOK_GLOBAL
End Sub
Private Sub Form_Unload(Cancel As Integer)
hook.StopHook WH_KEYBOARD_LL
Set hook = Nothing
Set apiLink = Nothing
End Sub
Private Sub hook_KeyDown(ByVal VKey As Long, ByVal scanCode _
As Long, ByVal ExtendedKey As Boolean, ByVal AltDown As _
Boolean, ByVal Injected As Boolean, Cancel As Boolean)
'Alt Tab
If AltDown And VKey = vbKeyTab Then
Cancel = True
'Alt Esc
ElseIf AltDown And VKey = vbKeyEscape Then
Cancel = True
'Ctrl Esc
ElseIf VKey = vbKeyEscape Then
'Check if a ctrl key down
If GetKeyState(vbKeyLCtrl) And &HF0000000 Or _
GetKeyState(vbKeyRCtrl) And &HF0000000 Then
Cancel = True
End If
'Windows key (L/R). Used to "disable" the start menu.
'Stops single keydown of a windows key
ElseIf VKey = vbKeyLWin Or VKey = vbKeyRWin Then
Cancel = True
'Windows + Any
'If there is a hotkey combination being pressed,
'the Windows key will not be stored in VKey,
'So I check the state of the windows keys.
'If they are down, cancel keys
Else
If GetKeyState(vbKeyLWin) And &HF0000000 Or _
GetKeyState(vbKeyRWin) And &HF0000000 Then
Cancel = True
End If
End If
'This is totally optional of course
If Cancel = True Then 'We have stopped some keystrokes. Beep
MessageBeep 0
End If
End Sub
And that's it. Post comments! =p If you see any errors, post, so we can get them fixed.
Thanks! Enjoy.
Last edited by wordracr; Dec 22nd, 2010 at 07:52 AM.