Click here to Skip to main content
15,896,154 members
Articles / Programming Languages / C++

Hooks and DLLs

Rate me:
Please Sign up or sign in to vote.
4.89/5 (81 votes)
31 Mar 200111 min read 1.6M   13.3K   335  
There is a lot of confusion about how to set up and use global hook functions. This essay attempts to clear up some of these issues.
#ifndef _DEFINED_44E531B1_14D3_11d5_A025_006067718D04
#define _DEFINED_44E531B1_14D3_11d5_A025_006067718D04
#if _MSC_VER > 1000
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#ifdef _COMPILING_44E531B1_14D3_11d5_A025_006067718D04
#define LIBSPEC __declspec(dllexport)
#else
#define LIBSPEC __declspec(dllimport)
#endif // _COMPILING_44E531B1_14D3_11d5_A025_006067718D04
   LIBSPEC BOOL setMyHook(HWND hWnd);
   LIBSPEC BOOL clearMyHook(HWND hWnd);
#undef LIBSPEC
#ifdef __cplusplus
}
#endif // __cplusplus
#define UWM_MOUSEMOVE_MSG _T("UWM_MOUSEMOVE_MSG-44E531B1_14D3_11d5_A025_006067718D04")

// These declarations are because the latest SDK isn't installed...
#ifndef GET_X_LPARAM
#define GET_X_LPARAM(p) ((int)(short)LOWORD(p))
#define GET_Y_LPARAM(p) ((int)(short)HIWORD(p))
#endif

#endif // _DEFINED_44E531B1_14D3_11d5_A025_006067718D04

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Retired
United States United States
PhD, Computer Science, Carnegie Mellon University, 1975
Certificate in Forensic Science and the Law, Duquesne University, 2008

Co-Author, [i]Win32 Programming[/i]

Comments and Discussions