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!
Printable View
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!
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
Be sure to first read the whole post before answering:
Quote:
I am able to disable Ctrl-Alt-Del and Alt-Esc.
Sorry...
I think the API you want is 'SetSysModalWindow'
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