Description
You use the WH_FOREGROUNDIDLE hook mainly to
allow
an application to do background processing when it is about to go
into an idle state. This type of processing is normally called
background processing because it occurs after
other more important processing has finished. An application achieves
an idle state when it has no more messages in the message queue to
process.
To be more specific, the system calls this hook when the foreground thread is about to enter an idle state. Every application has one foreground thread; any other thread is considered a background thread. Because Visual Basic (VB) applications run in a single thread, this thread is considered the foreground thread. If a VB application creates multiple threads, the system will call the hook only when the main or foreground thread is about to go into an idle state.
When the application is about to enter an idle state, the system will
check to see if any WH_FOREGROUNDIDLE hooks were
installed. If so, the system calls the first filter function
installed in the chain for this hook.
You can use this hook as a thread-specific hook, or you can place it in a dynamic link library (DLL) and use it as a system-wide hook. A thread-specific hook intercepts all messages within the thread in which it is installed. When you install a hook as a system-wide hook, you must place it in a DLL. This DLL is injected into every process so that the hook can operate on all messages in the system. Chapter 3 discusses this in detail. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access