Ctrl-Alt-Del can be disabled by changing a registry entry in XP, how are the other key combo's changed CTRL-ESC, ALT-F4, ALT-ESC ALT-Tab etc.
- Code: Select all
procedure DisableCtrAltDel(Val: Boolean);
var
MyReg: TRegistry;
begin
Try
MyReg := TRegistry.Create;
with MyReg do
begin
RootKey := HKEY_CURRENT_USER;
OpenKey('\Software\Microsoft\Windows\CurrentVersion\Policies\System', True);
if Val then
WriteString('DisableTaskMgr', '1')
else
DeleteValue('DisableTaskMgr');
CloseKey;
end;
Finally
MyReg.Free;
End;
end;
Another way is to use a keyboard hook and set certain key entries to 0 - here is an example I got form the Microsoft Developer Network but I dont really know how to change it to Delphi code.
Windows NT 4.0 Service Pack 3 and Later and Windows 2000
Applications can disable ALT+TAB or CTRL+ESC by installing a low-level keyboard hook. A low-level keyboard hook (WH_KEYBOARD_LL) is installed by calling SetWindowsHookEx. For more information on Window hooks see the "Hooks" overview in the Platform SDK documentation.
The following is a sample low-level keyboard hook procedure that disables CTRL+ESC, ALT+TAB, and ALT+ESC:
- Code: Select all
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);
}
Can anyone please help?