Click here to Skip to main content
15,896,382 members
Articles / Programming Languages / C#

Global System Hooks in .NET

Rate me:
Please Sign up or sign in to vote.
4.91/5 (146 votes)
9 Jan 2005CPOL18 min read 1.1M   49.2K   446  
A class library for using *global* system hooks in .NET.
// /////////////////////////////////////////////////////////////
// File: SystemHookCore.h	Class: none
// Date: 2/25/2004			Author: Michael Kennedy
// Language: C++			Framework: Win32
//
// Copyright: Copyright (c) Michael Kennedy, 2004-2005
// /////////////////////////////////////////////////////////////
// License: See License.txt file included with application.
// Description: See compiled documentation (Managed Hooks.chm)
// /////////////////////////////////////////////////////////////

#pragma once

namespace HookCoreErrors
{
	namespace SetCallBack
	{
		const int SUCCESS = 1;
		const int ALREADY_SET = -2;
		const int NOT_IMPLEMENTED = -3;
		const int ARGUMENT_ERROR = -4;
	}
	namespace FilterMessage
	{
		const int SUCCESS = 1;
		const int FAILED = -2;
		const int NOT_IMPLEMENTED = -3;
	}
}

typedef void (CALLBACK *HookProc)(int code, WPARAM w, LPARAM l);

int SetUserHookCallback(HookProc userProc, UINT hookID);
bool InitializeHook(UINT hookID, HINSTANCE appInstance, int threadID);
void UninitializeHook(UINT hookID);
void Dispose(UINT hookID);
int FilterMessage(UINT hookID, int message);
bool GetMousePosition(WPARAM wparam, LPARAM lparam, int & x, int & y);
bool GetKeyboardReading(WPARAM wparam, LPARAM lparam, int & vkCode);

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer DevelopMentor
United States United States
Michael Kennedy is a founding partner and software engineer at United Binary, LLC (http://www.unitedbinary.com [^]) and he is active in the agile software development community. Michael has been developing software for over 10 years. The last 4 of those years have been solidly focused on .NET development. For more information, please visit his website http://www.michaelckennedy.net [^]

In a previous life, Michael was pursuing a fairly successful career in mathematics before he saw the True Light and chose The Way of Programming.

Comments and Discussions