Et lille program der instalerer en hook og fjerner PageDown:
#include <windows.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
HHOOK MouseHook;
LRESULT LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode == HC_ACTION)
{
KBDLLHOOKSTRUCT *HookStruct = (KBDLLHOOKSTRUCT *)lParam;
if(HookStruct->vkCode == VK_NEXT)
{
return TRUE;
}
}
return CallNextHookEx(MouseHook, nCode, wParam, lParam);
}
void InstallHook(void)
{
if(MouseHook)
return;
MouseHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC )LowLevelKeyboardProc, GetModuleHandle(0), 0);
if(!MouseHook)
{
MessageBox(0, "Failed to install Hook", "NG27", MB_OK);
return;
}
}
void UnInstallHook(void)
{
if(MouseHook)
UnhookWindowsHookEx(MouseHook);
MouseHook = 0;
}
int main()
{
InstallHook();
MessageBox(0, "Hit Ok to close", "PageDown Remover", MB_OK);
UnInstallHook();
return 1;
}