HAr du andre ideer?
Jeg fandt en simplere metode; den bør ikke kunne fejle:
#include <windows.h>
HHOOK MouseHook;
HMODULE DllModule;
LRESULT __declspec(dllexport) 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)
{
char Fn[256];
if(MouseHook)
return;
GetModuleFileName(0, Fn, sizeof(Fn));
if((DllModule = GetModuleHandle(Fn)) == 0)
{
MessageBox(0, "Failed to find module", "NG27", MB_OK);
return;
}
MouseHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC )LowLevelKeyboardProc, DllModule, 0);
if(!MouseHook)
{
MessageBox(0, "Failed to install Hook", "NG27", MB_OK);
return;
}
}
void UnInstallHook(void)
{
if(MouseHook)
UnhookWindowsHookEx(MouseHook);
MouseHook = 0;
if(DllModule)
FreeLibrary(DllModule);
DllModule = 0;
}
int main()
{
InstallHook();
MessageBox(0, "Hit Ok to close", "PageDown Remover", MB_OK);
UnInstallHook();
return 1;
}