Thoroughly mask the task bar and the start menu through the API and keyboard hooks.

xiaoxiao2021-03-06  40

In some multimedia software compilation, it is usually necessary to completely block the task bar. The usual way is to call ShowWindow (H, SW_HIDE) to hide the task bar, but cannot block the start menu, the WIN function key through the keyboard can still open the start Menu, so match the keyboard hook to block the start menu.

Library hide;

{Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results This applies. to all strings passed to and from your DLL -.. even those that are nested in records and classes ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL to avoid using BORLNDMM.DLL PASS STRING INFORMATION USING PCHAR OR SHORTSTRING Parameters.

Uses sysutils, classes, windows, messages;

varhHk: HHOOK; type PKBDLLHOOKSTRUCT = ^ KBDLLHOOKSTRUCT; KBDLLHOOKSTRUCT = record vkCode: DWORD; ScanCode: DWORD; Flags: DWORD; Time: DWORD; dwExtraInfo: DWORD; end; {$ R * .res} function ycxsks (yc: Boolean): Boolean; stdcall; // Hide - Show Task Bar Varh: Thandle; Beginif Yc = TRUE THEN BEGIN H: = FindWindow ('shell_trayWnd', nil); showwindow (h, sw_hide); // Hide Task Bar Endelse Begin H: = FindWindow ('shell_traywnd', nil); showwindow (h, sw_show); // Displays task strips end; result: = true;

function keyHookProc (nCode: Integer; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall; // call keyboard hook, left and right shielding function keys win varp: PKBDLLHOOKSTRUCT; y: integer; beginif nCode <0 then Result: = CallNextHookEx (hHk , ncode, wparam, lparam) Else Begin Y: = 0; Case WPAram of WM_KeyDown, WM_SYSKEYDOWN: // After the button, the button is determined after the button Begin P: = pkbdllhookstruct (lparam); if p ^ .vkcode = vk_lwin THEN Y: = 1; IF p ^ .vkcode = vk_rwin life y: = 1; end; wm_keyup, wm_syskeyup: // Release button Begin P: = pkbdllhookstruct (lparam); if p ^ .vkcode = vk_lwin the: = 1; IF P ^ .vkcode = vk_rwin then y: = 1; end; end; if y = 1 Then Result: = 1 // If the WIN function key is shielded else result: = CallNexthooKex (HHK, NCODE, WPARAM, LPARAM); // other key drop a hook endend; function Enablehide: Boolean; stdcall; export; // external calls beginif hHk = 0 then begin hHk: = SetWindowsHookEx (13, @ keyHookProc, hInstance, 0); Result: = True; endelse Result : = False; ycxsks (true);

Function disablehide: boolean; stdcall; export; // external call Beginif hhk <> 0 dam; hHK: = 0; result: = true; endelse result: = false; ycxsks (false); end;

ExportSenableHide, DisableHide; end.

转载请注明原文地址:https://www.9cbs.com/read-66804.html

New Post(0)