you have to use hook procedures (global : entire system; or local : a single program or thread).
Basically, you'll be calling the following procedures :
- The SetWindowsHookEx function : to install a hook (monitor system event)
- The hook function : which is the procedure to be called by windows when the event we "hook" to happens.
- The UnhookWindowsHookEx function : to remove your hook
Here is a simple example of a local hook monitoring keyboard entries:
//setting up the hook;
//kbHook is a variable of type HHook (unit Windows);
//kbr_Hook is the procedure that will be called once the event happens;
kbHook:=setwindowshookex(WH_KEYBOARD,@kbr_Hook,0,GetCurrentThreadID());
MSDN documentation:
http://msdn.microsoft.com/en-us/library/ms644990%28VS.85%29.aspx
good luck