Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > API de Windows
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #3  
Antiguo 23-02-2011
leo007 leo007 is offline
Registrado
NULL
 
Registrado: feb 2011
Posts: 2
Poder: 0
leo007 Va por buen camino
Muchisimas gracias ,ahi algo encontre pero no se como pasarlo para que quede como .dll y se ejecute automaticamente una vez hookeado.

No se si me expreso bien (espero que si) yo tengo un Ejecutable al cual quiero hookearle la dll y que una vez iniciado el ejecutable inicie la dll y automaticamente bloquee las teclas-

Saludos y gracias .

Codigo encontrado :
Cita:
unit Hooks;

interface

type
{ Teclas que podemos inhabilitar }
TLockableKey = (lkAltTab, lkAltEsc, lkCtrlEsc, lkAltF4, lkWin, lkApps);

procedure SetHook;
procedure ReleaseHook;

procedure LockKey(Key: TLockableKey; Lock: Boolean);

implementation

uses
Windows;

const
{
Tipo de 'gancho'

Obsérvese que la documentación de Windows que viene
con Delphi no incluye este 'gancho' sino únicamente
WH_KEYBOARD que no intercepta estas teclas.
}
WH_KEYBOARD_LL = 13;

{ Banderas para detectar las teclas ALT y CTRL }
LLKHF_ALTDOWN = $20;
LLKHF_CTRLDOWN = $8000;

type
PKbdHookInfo = ^TKbdHookInfo;
TKbdHookInfo = record
VkCode: DWORD;
ScanCode: DWORD;
Flags: DWORD;
Time: DWORD;
ExtraInfo: DWORD;
end;

var
Hook: HHook;
Keys: set of TLockableKey;

function KbdHook(Code: Integer; WParam, LParam: DWORD): HHook; stdcall;
var
VkCode: DWORD;
AltDown: Boolean;
CtrlDown: Boolean;

begin
if Code = HC_ACTION then
begin
VkCode := PKbdHookInfo(LParam).VkCode;
AltDown := PKbdHookInfo(LParam).Flags and LLKHF_ALTDOWN <> 0;
CtrlDown := GetAsyncKeyState(VK_CONTROL) and LLKHF_CTRLDOWN <> 0;

if (VkCode = VK_TAB) and AltDown and (lkAltTab in Keys) then
begin
Result := 1;
exit;
end;

if (VkCode = VK_ESCAPE) then
begin
if AltDown and (lkAltEsc in Keys) then
begin
Result := 1;
exit;
end;

if CtrlDown and (lkCtrlEsc in Keys) then
begin
Result := 1;
exit;
end;
end;

if (VkCode = VK_F4) and AltDown and (lkAltF4 in Keys) then
begin
Result := 1;
exit;
end;

if ((VkCode = VK_LWIN) or (VkCode = VK_RWIN)) and (lkWin in Keys) then
begin
Result := 1;
exit;
end;

if (VkCode = VK_APPS) and (lkApps in Keys) then
begin
Result := 1;
exit;
end;
end;

Result := CallNextHookEx(Hook, Code, WParam, LParam);
end;

procedure SetHook;
begin
Hook := SetWindowsHookEx(WH_KEYBOARD_LL, @KbdHook, HInstance, 0);
end;

procedure ReleaseHook;

begin
if Hook <> 0 then UnhookWindowsHookEx(Hook);
end;

procedure LockKey(Key: TLockableKey; Lock: Boolean);
begin
if Lock then Include(Keys, Key) else Exclude(Keys, Key);
end;

initialization
Hook := 0;
Keys := [];

finalization
ReleaseHook;
end.
Fuente :roman.clubdelphi
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Bloquear Teclas en XP syul API de Windows 14 17-08-2011 12:21:33
Bloquear teclas CTRL+ALT+SUPR en Windows 7 octavioallec API de Windows 5 07-03-2011 20:08:40
bloquear teclas cmm07 Varios 11 01-10-2008 13:11:10
bloquear teclas de función windows+* 2-D@monic API de Windows 2 19-11-2007 04:30:56
Bloquear Combinaciones de Teclas. D-MO Varios 6 24-11-2006 03:25:10


La franja horaria es GMT +2. Ahora son las 13:03:34.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi