I wrote a simple hook program that should print out "Key pressed" whenever a key is pressed but whenever I press something the computer freezes for 5 seconds or so and the application doesn't print out anything. Here is the code:
Documentation over guessing. In particular, read the remarks section for what is required for the hook to work.
This hook is called in the context of the thread that installed it. The call is made by sending a message to the thread that installed the hook. Therefore, the thread that installed the hook must have a message loop.
I replaced cin.get() with while(GetMessage(NULL, NULL, 0, 0)); Is that ok or am I doing something wrong. The program worked and the freezing stopped too.