Yo tengo unas rutinas que te pueden servir, yo las gasto para evitar que me cierren la aplicacion o cambien de tarea, asi pues deshabilito el administrador de tareas y las combinaciones [ESC+CTRL] [ALT+TAB] [CTRL+ALT+SUP]
Despues de consular en foros y paginas de trucos ... "he construido" esto:
Bloquear_Teclas_windows(valor:boolean);
y el codigo es:
procedure Bloquear_Teclas_windows(valor:boolean);
var dummy:integer;
begin
if valor then SetHook;
LockKey(lkAltTab,valor);
LockKey(lkAltEsc,valor);
LockKey(lkCtrlEsc,valor);
LockKey(lkAltF4,valor);
LockKey(lkWin,valor);
LockKey(lkApps,valor);
if Not valor then ReleaseHook;
teclasWinBloq:=Valor;
if Valor then SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @dummy, 0)
else SystemParametersInfo( SPI_SCREENSAVERRUNNING, 0, @dummy, 0);
DisableTaskMgr(valor);
if Not valor then LockWorkStation;
end;
procedure DisableTaskMgr(bTF: Boolean);
var
reg: TRegistry;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKey('Software', True);
reg.OpenKey('Microsoft', True);
reg.OpenKey('Windows', True);
reg.OpenKey('CurrentVersion', True);
reg.OpenKey('Policies', True);
reg.OpenKey('System', True);
if bTF = True then
begin
reg.WriteString('DisableTaskMgr', '1');
end
else if bTF = False then
begin
reg.DeleteValue('DisableTaskMgr');
end;
reg.CloseKey;
end;
function LockWS: Boolean;
// by Thomas Stutz, SDC
type
TLockWorkStation = function: Boolean;
var
hUser32: HMODULE;
LockWorkStation: TLockWorkStation;
begin
// Here we import the function from USER32.DLL
bloq_estacion:=False;
hUser32 := GetModuleHandle('USER32.DLL');
if hUser32 <> 0 then
begin
@LockWorkStation := GetProcAddress(hUser32, 'LockWorkStation');
if @LockWorkStation <> nil then
begin
LockWorkStation;
Result := True;
bloq_estacion:=True;
end;
end;
end;
Espero que te sirva.
|