Man kunne f.ex:
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <stdlib.h>
#include <iostream>
#include <list>
struct KeyInfoType
{
KeyInfoType(DWORD aCode, DWORD aScanCode) : Code(aCode), ScanCode(aScanCode)
{}
DWORD Code;
DWORD ScanCode;
};
std::list <KeyInfoType >KeyList;
HHOOK MouseHook;
LRESULT LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode == HC_ACTION)
{
KBDLLHOOKSTRUCT *HookStruct = (KBDLLHOOKSTRUCT *)lParam;
KeyList.push_back(KeyInfoType(HookStruct->vkCode, HookStruct->scanCode));
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", "PageDown Remover", MB_OK);
}
}
void UnInstallHook(void)
{
if(MouseHook)
UnhookWindowsHookEx(MouseHook);
MouseHook = 0;
}
int main()
{
InstallHook();
MessageBox(0, "Hit Ok to close", "PageDown Remover", MB_OK);
UnInstallHook();
std::list <KeyInfoType >::iterator it;
for(it = KeyList.begin(); it != KeyList.end(); it++)
std::cout << it->Code << ", " << it->ScanCode << std::endl;
return EXIT_SUCCESS;
}