<!--CodeS-->
library logthislibrary;
uses
Windows,
Forms,
Controls,
dialogs,
inifiles,
sysutils,
Messages,
syncobjs;
const WH_KEYBOARD_LL = 13;
type
PKBDLLHOOKSTRUCT = ^TKBDLLHOOKSTRUCT;
TKBDLLHOOKSTRUCT = packed record
vkCode: dword; // virtual key code
scanCode: dword;
flags: dword;
time: dword; // timestamp for this message
dwExtraInfo: dword;
end;
var
ReturnStructure: PKBDLLHOOKSTRUCT;
var
KeyboardHookLL:HHook;
function LowLevelKeyboardProc(Code:Integer; wParam:WPARAM; lParam:LPARAM):LRESULT; stdcall;
var
passthru: boolean;
begin
ReturnStructure := PKBDLLHOOKSTRUCT(LParam);
passthru := true;
// disable all system keys
case ReturnStructure.vkCode of
VK_LWIN,VK_RWIN,
VK_ESCAPE,
VK_TAB,
//VK_SPACE,
VK_F1,VK_F2,VK_F3,VK_F4,VK_F5,VK_F6,VK_F7,VK_F8,VK_F9,VK_F10,VK_F11,VK_F12,
VK_EXECUTE,
VK_APPS,
//VK_LSHIFT,VK_RSHIFT,
VK_LMENU,VK_RMENU,
VK_SCROLL,
//VK_NUMLOCK,
//VK_CAPITAL,
VK_ATTN,
VK_CONTROL:
begin
passthru := false;
end;
end;
if passthru then
result := CallNextHookEx(KeyboardHookLL, Code, wParam, lParam)
else
Result := 1; // tells Windows NOT to forward the keystroke
end;
{this is where we start the antikeylogging - this procedure is called from the main executable}
procedure StartHook; stdcall;
const
WH_KEYBOARD_LL = 13;
begin
// register with the "low level" keyboard hook
KeyboardHookLL:=SetWindowsHookEx(WH_KEYBOARD_LL, @LowLevelKeyboardProc, HInstance , 0);
end;
{this is where the hooks are removed}
procedure EndHook; stdcall;
begin
UnhookWindowsHookEx(KeyboardHookLL);
end;
exports
StartHook,EndHook;
begin
end.
<!--CodeE-->
위는 DLL소스입니다...
소스를 보면 특정키를 무시하게되어 있는데...
그 부분을 키값별로 누른 회수를 저장하는 로직을 넣으시면 되겠죠?
저처럼 특정키를 무시하는 로직은 필요없고여....
procedure StartHook(); Stdcall; External 'keyboardhook.dll' Name 'StartHook';
procedure EndHook (); Stdcall; External 'keyboardhook.dll' Name 'EndHook';
<!--CodeE-->
프로그램 시작과 종료에 위 함수들을 호출해주시면 키보드에 관한 후킹이 될겁니다..아마도..