Posted by webmaster Guido on April 27, 2003 at 17:18:16:
In Reply to: Disabling Access to Windows posted by Carlos Pimentel on April 23, 2003 at 23:23:00:
: I need lock access to windows disabling (ctrl-alt-dell), (alt-tab), (ctrl-esc) e (windows key).
: I tried to use SystemParametersInfo(97, Word(True), @OldValue, 0) but doesn't works on Delphi6 and WindowsXP. Could you help me?
To disable the keyboard keys that are called "system keys" (CTRL-ALT-ESC, CTRL-ESC, ALT-TAB, Windows key...), the code below works well under Win98 and Delphi 6, but I didn't test it under Windows XP. Maybe something changed under XP?
To test it: start a new project, add two buttons to the main form and write these event handlers:
procedure TForm1.btnLockClick(Sender: TObject); var i: integer; begin // Lock the system keys: CTRL-ALT-ESC, CTRL-ESC, ALT-TAB, Windows key... SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @i, 0); end; procedure TForm1.btnUnlockClick(Sender: TObject); var i: integer; begin // Unlock the system keys, after they were locked SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, @i, 0); end;
Note: when the Windows-key is locked, you can not open Windows' Start menu from the keyboard anymore, but it's still possible to open the Start menu by clicking the Windows' Start button in the Taskbar. So the user still can start other programs from the Start Menu, or stop Windows. If you want to prevent this, you also have to hide the Start button from Windows's Taskbar, or hide the Taskbar completely. That's possible with Delphi.