ClanStyles 0 Newbie Poster
#include <iostream>
#include <windows.h>

using namespace std;

HHOOK g_KeyboardHook = NULL;

LRESULT CALLBACK cbHookKeyboard(int nCode, WPARAM wParam, LPARAM lParam);

int main(int argc, char *argv[])
{
    g_KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)cbHookKeyboard, GetModuleHandle(NULL), 0);
    while(true) { }
    return EXIT_SUCCESS;
}

LRESULT CALLBACK cbHookKeyboard(int nCode, WPARAM wParam, LPARAM lParam) {
        if(nCode == HC_ACTION)
        {
                 KBDLLHOOKSTRUCT* pKeyBoard = (KBDLLHOOKSTRUCT *)wParam;
                 printf("Hey KEY: %u", pKeyBoard->vkCode);
        }
        return CallNextHookEx( g_KeyboardHook, nCode, wParam, lParam );
}

Doesn't work, I don't think the hook is ever being put in place.

I'm trying to do a "legal" hook for key events. I want to detect them so I can check what you type for locking out specific keys. But, I know GetAsycncKey or w/e is picked up by AV's usually as a virus (Generic) and I want to avoid this at all costs.

Any clues?