problems with hooks in windows 98
Posted on 2003-03-03
Hi, I've trying to make a keyboard hook work and I thought I had succeded (because it worked fine in Win 2000) but when I tested the program in Windows 98 I realized I hadn't.
The executable just calls the DLL with LoadLibrary and the DLL should do all the job. The problem in Windows 98 is that when i run the program and I press any key (so the callback function of the SetWindowsHookEx is run by Windows) i get a Windows serious message about a memory problem, and then I have to reboot the system because everything gets slow (even thought I have closed the program!!).
I did the same thing not using a DLL, just putting all the code in an executable and it works fine but it doesn't get all the keystrokes, that's why I need to do it with a DLL.
I hope you can help me, give a clue or something.
Here it is the skeleton. With only this, the program crashs when I touch a key:
LRESULT CALLBACK callb(int nCode, WORD wParam, DWORD lParam );
static HINSTANCE hDLLInstance;
hook = SetWindowsHookEx(WH_KEYBOARD,
if (hook == NULL) MessageBox(NULL,"Hook = NULL","Error",MB_OK);
LRESULT CALLBACK callb(int nCode, WORD wParam, DWORD lParam )
LRESULT NextHook = CallNextHookEx( hook, nCode, wParam, lParam );
BOOL APIENTRY DllMain( HINSTANCE hInstance,
hDLLInstance = hInstance;