Under Windows 3.x and 95/98 you can prevent that a user switches to another application with the following code which pretends to be a screensaver running. This does not work under Windows NT.
// You may need the following definition of SPI_SCREENSAVERRUNNING:
const
SPI_SCREENSAVERRUNNING = 97;
var
OldValue: Longint;
begin
// disable task switching
SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, OldValue, 0);
// enable task switching
SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, OldValue, 0);
end.