GetAsyncKeyState возвращает не int, а short.
-32767 в int и short имеют разные значения на уровне битов - по тому условие никогда не срабатывает
Как мне кажется - проще будет сравнивать с нулём, а не с -32767.
Ну и есть ещё дополнительные причины, по которым эта функция всегда возвращает 0:
If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. However, you should not rely on this last behavior; for more information, see the Remarks.
The return value is zero for the following cases:
- The current desktop is not the active desktop
- The foreground thread belongs to another process and the desktop does not allow the hook or the journal record.
Стоит отметить, что прога вылетает не просто так, предварительно в правом нижнем углу вылезает защитник Windows и орет, мол эта штука использует какие то там интсрументы
Лучше напиши конкретно, что там за текст написан.
Вообще, раз уж ты пишешь кейлоггер, то защитник винды не просто так ругается :) - просто выключи его