unit lockit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons, Tlhelp32;
const
WM_HOOKCREATE = WM_USER + 1;
function SetHook(WinHandle: HWND; MsgToSend: integer): boolean; stdcall; external 'winhook.dll';
function FreeHook: boolean; stdcall; external 'winhook.dll';
procedure HideTaskbar;
procedure ShowTaskbar;
procedure lockwindowskey;
procedure freewindowskey;
procedure lockalttab;
procedure freealttab;
procedure showwindowsbutton;
procedure hidewindowsbutton;
function KillTask(ExeFileName: string): integer;
var FHookSet: Boolean;
implementation
procedure HideTaskbar;
var
wndHandle : THandle;
wndClass : array[0..50] of Char;
begin
StrPCopy(@wndClass[0], 'Shell_TrayWnd');
wndHandle := FindWindow(@wndClass[0], nil);
ShowWindow(wndHandle, SW_HIDE); {This hides the taskbar}
end;
procedure ShowTaskbar;
var
wndHandle : THandle;
wndClass : array[0..50] of Char;
begin
StrPCopy(@wndClass[0], 'Shell_TrayWnd');
wndHandle := FindWindow(@wndClass[0], nil);
ShowWindow(wndHandle, SW_RESTORE); {This restores the taskbar}
end;
procedure lockwindowskey;
var
handle:thandle;
begin
FHookSet := LongBool(SetHook(
Handle,WM_HOOKCREATE));
end;
procedure freewindowskey;
begin
FHookSet := FreeHook;
end;
procedure lockalttab;
var OldVal : LongInt;
begin
SystemParametersInfo (97, Word (True), @OldVal, 0);
end;
procedure freealttab;
var OldVal : LongInt;
begin
SystemParametersInfo (97, Word (false), @OldVal, 0);
end;
procedure showwindowsbutton;
begin
EnableWindow(FindWindowEx(FindWindow
('Shell_TrayWnd', nil), 0,'Button',nil),true);
end;
procedure hidewindowsbutton;
begin
EnableWindow(FindWindowEx(FindWindow
('Shell_TrayWnd', nil), 0,'Button',nil),false);
end;
function KillTask(ExeFileName: string): integer;
const
PROCESS_TERMINATE=$0001;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
result := 0;
FSnapshotHandle := CreateToolhelp32Snapshot
(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle,
FProcessEntry32);
while integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName))
or (UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then
Result := Integer(TerminateProcess(OpenProcess(
PROCESS_TERMINATE, BOOL(0),
FProcessEntry32.th32ProcessID), 0));
ContinueLoop := Process32Next(FSnapshotHandle,
FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
end.