I am developing a utility that intercepts keyboard messages (WM_KEYxx, WM_SYSKEYxx) and discards them by setting the message field to WM_NULL. This is supposed to effectively lock out the keyboard because I would like to prevent users from using the keyboard when my utility is running unless they have an unlock key. The problem is I am getting a runtime error when I close the application that has the input focus. The hook type I used is system wide. Is there a way to prevent Windows from sending the message to the destination window. Any help will be highly appreciated.