SetWindowsHookEx( )
this method allows a function to be added in the hook chain for particular events. For example:
WH_CALLWNDPROC
WH_KEYBOARD
WH_CALLWNDPROCRET
etc.
So if we want to have a user defined function to be called for a certain windows event we can install a hook and then write our own procedure to handle the event.
for more: http://msdn.microsoft.com/en-us/library/ms644990(v=vs.85).aspx