Results 1 to 40 of 58

Thread: VB-Disable Ctrl Alt Del in XP, Hide TaskBar, Disable Windows keys

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member wordracr's Avatar
    Join Date
    Aug 2001
    Posts
    281

    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.
    VB Code:
    1. Private Sub ToggleTaskBar()
    2.     Dim TaskBarWnd As Long
    3.    
    4.     TaskBarWnd = FindWindow("Shell_TrayWnd", vbNullString)
    5.     If IsWindowVisible(TaskBarWnd) Then
    6.         Call ShowWindow(TaskBarWnd, SW_HIDE)
    7.     Else
    8.         Call ShowWindow(TaskBarWnd, SW_SHOW)
    9.     End If
    10. End Sub



    --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:
    1. Private Declare Function MessageBeep Lib "user32" (ByVal wType As Long) As Long
    2. Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    3.  
    4. Private WithEvents apiLink As EventVB.APIFunctions
    5. Private WithEvents hook As EventVB.ApiSystemHook
    6.  
    7. Private Const vbKeyLWin As Integer = 91
    8. Private Const vbKeyRWin As Integer = 92
    9. Private Const vbKeyLCtrl As Integer = 162
    10. Private Const vbKeyRCtrl As Integer = 163

    And then for the events:
    VB Code:
    1. Private Sub Form_Load()
    2.   Set apiLink = New EventVB.APIFunctions
    3.   Set hook = apiLink.System.Hooks
    4.  
    5.   hook.StartHook WH_KEYBOARD_LL, HOOK_GLOBAL
    6.  
    7. End Sub
    8.  
    9. Private Sub Form_Unload(Cancel As Integer)
    10.    hook.StopHook WH_KEYBOARD_LL
    11.    Set hook = Nothing
    12.    Set apiLink = Nothing
    13. End Sub
    14.  
    15. Private Sub hook_KeyDown(ByVal VKey As Long, ByVal scanCode _
    16.     As Long, ByVal ExtendedKey As Boolean, ByVal AltDown As _
    17.     Boolean, ByVal Injected As Boolean, Cancel As Boolean)
    18.  
    19.     'Alt Tab
    20.     If AltDown And VKey = vbKeyTab Then
    21.         Cancel = True
    22.    
    23.     'Alt Esc
    24.     ElseIf AltDown And VKey = vbKeyEscape Then
    25.         Cancel = True
    26.    
    27.     'Ctrl Esc
    28.     ElseIf VKey = vbKeyEscape Then
    29.         'Check if a ctrl key down
    30.         If GetKeyState(vbKeyLCtrl) And &HF0000000 Or _
    31.             GetKeyState(vbKeyRCtrl) And &HF0000000 Then
    32.             Cancel = True
    33.         End If
    34.        
    35.     'Windows key (L/R). Used to "disable" the start menu.  
    36.     'Stops single keydown of a windows key
    37.     ElseIf VKey = vbKeyLWin Or VKey = vbKeyRWin Then
    38.         Cancel = True
    39.    
    40.     'Windows + Any
    41.     'If there is a hotkey combination being pressed,
    42.     'the Windows key will not be stored in VKey,
    43.     'So I check the state of the windows keys.  
    44.     'If they are down, cancel keys
    45.     Else
    46.         If GetKeyState(vbKeyLWin) And &HF0000000 Or _
    47.             GetKeyState(vbKeyRWin) And &HF0000000 Then
    48.             Cancel = True
    49.         End If
    50.     End If
    51.    
    52.     'This is totally optional of course
    53.     If Cancel = True Then 'We have stopped some keystrokes. Beep
    54.         MessageBeep 0
    55.     End If
    56.    
    57. End Sub

    And that's it. Post comments! =p If you see any errors, post, so we can get them fixed.

    Thanks! Enjoy.
    Attached Files Attached Files
    Last edited by wordracr; Dec 22nd, 2010 at 07:52 AM.

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