Results 1 to 6 of 6

Thread: Disable Desktop Windows Alt-F4 keys

  1. #1
    Guest

    Can you help me find an API call I can use to
    disable from VB the Desktop Windows Short-Cut Alt-F4 keys to prevent unauthorized users from closing Windows?

    I am able to disable Ctrl-Alt-Del and Alt-Esc.

    Thanks!



  2. #2
    Guest
    You can try this to disable the CTRL-ALT-DEL keys.

    Private Const SPI_SCREENSAVERRUNNING = 97&

    Private Declare Function SystemParametersInfo Lib "User32" _
    Alias "SystemParametersInfoA" _
    (ByVal uAction As Long, _
    ByVal uParam As Long, _
    lpvParam As Any, _
    ByVal fuWinIni As Long) As Long

    Private Sub Disable_Click()
    Dim lngRet As Long
    Dim blnOld As Boolean
    lngRet = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, _
    blnOld, _
    0&)
    End Sub

    Private Sub Enable_Click()
    Dim lngRet As Long
    Dim blnOld As Boolean
    lngRet = SystemParametersInfo SPI_SCREENSAVERRUNNING, False, _
    blnOld, _
    0&)
    End Sub

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Be sure to first read the whole post before answering:

    I am able to disable Ctrl-Alt-Del and Alt-Esc.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    Guest

    Angry

    Sorry...

  5. #5
    Guest
    I think the API you want is 'SetSysModalWindow'

  6. #6
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    No no, guys, this is the solution:

    Code:
    '
    '   Locates the Windows TaskBar
    '
    Private Function FindShellTaskBar() As Long
    
    Dim hWnd As Long
    
    On Error Resume Next
    
    hWnd = FindWindowEx(0&, 0&, g_cstrShellTaskBarWnd, vbNullString)
    
    If hWnd <> 0 Then
        FindShellTaskBar = hWnd
        
    End If
        
    End Function
    '
    '   Locates the shell_defview window
    '
    Private Function FindShellWindow() As Long
    
    Dim hWnd As Long
    
    On Error Resume Next
    
    hWnd = FindWindowEx(0&, 0&, g_cstrShellViewWnd, vbNullString)
    
    If hWnd <> 0 Then
        FindShellWindow = hWnd
        
    End If
        
    End Function
    
    
    '
    '   Toggles a window's visibility
    '
    Private Sub HideShowWindow(ByVal hWnd As Long, Optional ByVal Hide As Boolean = False)
    
    Dim lngShowCmd As Long
    
    On Error Resume Next
    
    If Hide = True Then
        lngShowCmd = SW_HIDE
        
    Else
        lngShowCmd = SW_SHOW
        
    End If
    
    Call ShowWindow(hWnd, lngShowCmd)
    
    
    End Sub
    
    Private Sub cdShowDesktop_Click()
    
    Dim hWnd As Long
    
    On Error Resume Next
    
    '// Find the window we're looking for and then hide it
    hWnd = FindShellWindow()
    
    If hWnd <> 0 Then
    
        Call HideShowWindow(hWnd)
        
    End If
    
    End Sub
    
    Private Sub cmdHideDesktop_Click()
    
    Dim hWnd As Long
    
    On Error Resume Next
    
    hWnd = FindShellWindow()
    
    If hWnd <> 0 Then
        Call HideShowWindow(hWnd, True)
        
    End If
    
    End Sub
    
    
    Private Sub cmdHideTaskBar_Click()
    
    Dim hWnd As Long
    
    On Error Resume Next
    
    hWnd = FindShellTaskBar()
    
    If hWnd <> 0 Then
    
        Call HideShowWindow(hWnd, True)
        
    End If
    
    
    End Sub
    
    
    Private Sub cmdShowTaskBar_Click()
    
    Dim hWnd As Long
    
    On Error Resume Next
    
    hWnd = FindShellTaskBar()
    
    If hWnd <> 0 Then
    
        Call HideShowWindow(hWnd)
        
    End If
    
    End Sub

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