Author: Tomas Rutkauskas
How to deactivate and reactivate [CTRL] + [ALT] + [DEL] or [ALT] + [TAB] key
combinations
Answer:
Solve 1:
1 unit Unit1;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
7
8 type
9 TForm1 = class(TForm)
10 procedure FormCreate(Sender: TObject);
11 private
12 { Private declarations }
13 public
14 { Public declarations }
15 end;
16
17 var
18 Form1: TForm1;
19
20 const
21 RSP_SIMPLE_SERVICE = 1;
22 RSP_UNREGISTER_SERVICE = 0;
23
24 type
25 TRegisterServiceProcess = function(dwProcessID, dwType: DWORD): DWORD; stdcall;
26
27 implementation
28
29 {$R *.DFM}
30
31 procedure TForm1.FormCreate(Sender: TObject);
32 var
33 Hndl: THandle;
34 begin
35 Hndl := LoadLibrary('KERNEL32.DLL');
36 @RegisterServiceProcess := GetProcAddress(Hndl, 'RegisterServiceProcess');
37 if @RegisterServiceProcess < > nil then
38 {check for function, if its there load it}
39 RegisterServiceProcess(GetCurrentProcessID, RSP_SIMPLE_SERVICE);
40 FreeLibrary(Hndl);
41 end;
42
43 end.
Solve 2:
On Windows 95/ 98/ ME you can disallow CTRL + ALT + DEL in a straight forward
manner:
44 procedure DisableCtrlAltDel;
45 var
46 Dummy: Integer;
47 begin
48 Dummy := 0;
49 SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @Dummy, 0)
50 end;
51
52 procedure EnableCtrlAltDel;
53 var
54 Dummy: Integer;
55 begin
56 Dummy := 0;
57 SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, @Dummy, 0)
58 end;
59
60
61 {In fact, the above code snippets will disable Ctrl+Esc too. To disable ALT + TAB,
62 you can use:}
63
64
65 procedure DisableAltTab;
66 var
67 Dummy: Integer;
68 begin
69 Dummy := 0;
70 SystemParametersInfo(SPI_SETFASTTASKSWITCH, 1, @Dummy, 0);
71 end;
72
73 procedure EnableAltTab;
74 var
75 Dummy: Integer;
76 begin
77 Dummy := 0;
78 SystemParametersInfo(SPI_SETFASTTASKSWITCH, 0, @Dummy, 0);
79 end;
All this is still for Windows 95/ 98/ ME. On NT based systems (Windows NT/ 2000), you can get rid of Alt+Tab and Ctrl+Esc in normal manner (different from the above snippets). But to disable Ctrl+Alt+Del, you need to perform key-remapping and that is a bit tricky. Doing key-remapping can render a system useless if not done properly. You need to do a reinstall in such a case.
|