Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
Hello,
I am planning to make a programm to disable the windows special keys like Ctrl+Esc, Alt+Ctrl+Del,Alt+Tab and windows logo key. I have developed the program for 98 but it is not working in windows xp. I would like to disable these key independent of operating system. Your help will be appricaited
Thankx
# 1 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
do a search for "HOWTO: Disable Task Switching on Win32 Platforms" in your msdn or in the online msdn.
according to this document you have to install a low level keyboard hook that traps these messages.
on 95-me machines it describes using the following functions
UINT nPreviousState;
// Disables task switching
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);
// Enables task switching
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);
but NT and about it talks about keyboard hooks and gives the following example
The following is a sample low-level keyboard hook procedure that disables CTRL+ESC, ALT+TAB, and ALT+ESC:
LRESULT CALLBACK LowLevelKeyboardProc (INT nCode, WPARAM wParam, LPARAM lParam)
{
// By returning a non-zero value from the hook procedure, the
// message does not get passed to the target window
KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
BOOL bControlKeyDown = 0;
switch (nCode)
{
case HC_ACTION:
{
// Check to see if the CTRL key is pressed
bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
// Disable CTRL+ESC
if (pkbhs->vkCode == VK_ESCAPE && bControlKeyDown)
return 1;
// Disable ALT+TAB
if (pkbhs->vkCode == VK_TAB && pkbhs->flags & LLKHF_ALTDOWN)
return 1;
// Disable ALT+ESC
if (pkbhs->vkCode == VK_ESCAPE && pkbhs->flags & LLKHF_ALTDOWN)
return 1;
break;
}
default:
break;
}
return CallNextHookEx (hHook, nCode, wParam, lParam);
}
i need to implement this mysefl, so if you have any trouble let me know and i'll show you once i've done it.
regards,
jai
# 2 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
you cannot disable or hook into Ctrl+Alt+Del for security reasons
cjard at 2007-11-9 23:20:18 >

# 3 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
for "Disableing" ctrl , alt, delete, you can kill the app
'add a timer and set it to 200 interveral
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Private Sub Form_Load()
Timer1.Enabled = True
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Timer1.Enabled = False
End Sub
Private Sub Form_Resize()
Me.Hide
End Sub
Private Sub Timer1_Timer()
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = "Windows Task Manager" '= InputBox("Windows Task Manager:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then
Exit Sub
End If
'close it...
PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub
Now for someone not to exit the program (i think for the most part)
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = 1
End Sub
# 4 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
The Ctrl+Alt+Del can be disabled.
Do a search on "msgina.dll". This file is responsable for Ctrl+Alt+Del, Logins and other stuff. There is the source of this file in MSDN. I do not have time at the moment but in 24 hours I can explain in detail this technique if you haven't done it allready :)
vma at 2007-11-9 23:22:17 >

# 5 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
Just to backup VMA - Here's the link to OLMSDN ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/msgina_dll_features.asp). It explains all you need to know to get you started I think. I only browsed through it.
# 6 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
The Ctrl+Alt+Del can be disabled.
Do a search on "msgina.dll". [...] I do not have time at the moment
but in 24 hours I can explain in detail this technique if you haven't
done it allready :)
Curious to see how you can make a replacemet for MsGina in Vb...
# 7 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
Ok you are right, there is no way to change msgina.dll with VB. The code from MSDN is in C.
Winlogon calls function WlxLoggedOnSAS from msgina when it receives a "secure attention sequence" better known as Ctrl+Alt+Del. You can change your msgina so that WlxLoggedOnSAS returns FALSE when such a sequence is received. That way nothing happens when Ctrl+Alt+Del is pressed.
I am sorry that I forgot about this thread when I got home but today I'll attach a msgina that works for me on XP. With this msgina you don't need to know C just replace the old file.
vma at 2007-11-9 23:25:21 >

# 8 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
This question has been asked a lot of times on this forum, check out KeyboardControl SDK ( http://www.meliorasoft.com/kits/), I'm using this tool, works great in both VB and C++ :thumb:
DEX348 at 2007-11-9 23:26:26 >

# 9 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
[...]I'm using this tool, works great in both VB and C++
Better read carefully documentation, expecially pages 22 and 23...
Btw,
Price: 299.00$
check budget...
and
Join Date: Apr 2004, Posts: 1
This is all you have said here. You sure you are not a seller?
# 10 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
well done,but there is a little problem,the problem is that not exist the title of "Windows Task Manager" when i pressed Ctrl+Alt+Del keys.what should i do it?
for "Disableing" ctrl , alt, delete, you can kill the app
'add a timer and set it to 200 interveral
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Private Sub Form_Load()
Timer1.Enabled = True
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Timer1.Enabled = False
End Sub
Private Sub Form_Resize()
Me.Hide
End Sub
Private Sub Timer1_Timer()
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = "Windows Task Manager" '= InputBox("Windows Task Manager:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then
Exit Sub
End If
'close it...
PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub
Now for someone not to exit the program (i think for the most part)
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = 1
End Sub
# 11 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
well done,but there is a little problem,the problem is that not exist the title of "Windows Task Manager" when i pressed Ctrl+Alt+Del keys.what should i do it?
That trick is to close the Task Manager as sooon as it shows up.
But when you press Ctrl+Alt+Canc, you first get the "Window security"
window, which you cannot close that easy.
Task Manager is only one option within that window, where you could also
choose to lock workstation, for example, or to shut down your Pc...
The answer focused on Task Manager as if user wants to close a running
process would most likely kill it via Task Manager. Thus trick provided is not
meant to stop Ctrl+Alt+Canc, but to prevent user to access Task manager...
# 12 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
Better read carefully documentation, expecially pages 22 and 23...
It says something on msgina, to tell you the truth I didn't read those pages thoroughly, but for gina I used the demo vb project as example and called
KCInitialize(INIT_COMPATIBLE_MODE). Btw, I posted on this forum earlier, I wouldn't register in Apr to start posing in Aug.
DEX348 at 2007-11-9 23:30:26 >

# 13 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
also, it's possible to remap keys in registry, for XP it should work ok.
DEX348 at 2007-11-9 23:31:29 >

# 14 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
Btw, I posted on this forum earlier, I wouldn't register
in Apr to start posing in Aug.
Not a seroius matter (=that is: hope no arm for this), but I am not able to
find your previous posts.
This may means:
-You deleted them
-We deleted them (ie: they were judged to break Aup [=see
"Rules in dev-archive" link in my signature])
In any case, your actual post is accepted: it might be a solution for all those
who would like to trap the keys combinations.
Only one question: docs of that demo said you
could trap only three keys - and, as per documentation, as they are not
all the three pointed here, you should not be able to track Ctrl+Alt+Canc.
How could you trap that sequence with the demo?
(ies, I could test myuself, but am somewhat reluctant to install a hook like that... ;) )
# 15 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
yes, the demo doesn't allow to trap Ctrl+Alt+Canc, just Alt+Tab and Win, patelmurtuza asked about them as well.
DEX348 at 2007-11-9 23:33:30 >

# 16 Re: Disable ctrl+esc, Ctrl+alt+Del,windows logo key for win XP OS
ok here is the dll and the asociate reg file to change the registry. Be careull to note the registry key down to be able to remove it later.
INSTALATION:
I
1. Copy the msgina.dll file from windows\system32 to a safe location
2. Rename the dll in this archive to msgina.dll and overwrite the one in system32.
3. Reboot
backup: overwrite the original msgina back to system32, reboot
II
a. note the registry key that is about to be changed
b. run the reg file in archive
c. copy the dll from the archive in windows\system32
d. reboot
backup: from outer sources delete the key from registries, reboot
DISCLAIMER: The following app can distroy your computer without the oportunity to make it back only by reinstalling windows. Don't use it if you are not sure what are you doing.
vma at 2007-11-9 23:34:24 >
