Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2007, 10:49 PM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Installing A system wide CBT hook

Hi im trying to install a CBT system wide hook.
In the hook callback method i just simply write the code parameter to the debug window.

My code works fine when i specify a specific thread to monitor,
however when i try and install a system wide hook using SetWindowsHookEx
it prints to the debug window until i move the mouse out of the programs window, at which point it stops, and the callback is no longer called.
If i return the mouse to the same window, the callback still doesnt get called.

I have also tried setting a system wide low level keyboard hook using the same code, but that works fine.

here is my code to initiate the hook system wide CBT hook:

//Retrieve current threads module name
string moduleName = Process.GetCurrentProcess().MainModule.ModuleName;

hhook = SetWindowsHookEx(m_hookType, m_filterFunc, GetModuleHandle (moduleName ), (int)0);

Im using the GetModuleHandle Api to retrieve the handle for the current module running.

here is the code for the callback function

protected int CoreHookProc(int code, IntPtr wParam, IntPtr lParam)
{
Debug.WriteLine("code " + code + "." + DateTime.Now.Millisecond);
if (code < 0)
return CallNextHookEx(m_hhook, code, wParam, lParam);

If anyone has any idea how to work around this problem, i would be most grateful to here from you.

thanks very much:(






Similar Threads
Thread Thread Starter Forum Replies Last Post
mouse hook question dartcoach VB How-To 1 September 12th, 2007 08:30 AM
Hook method yfzzky Java Basics 1 April 27th, 2007 09:35 AM
USB devices connect Hook -- ??? Demokratizator C# 0 June 17th, 2006 12:34 PM
global mouse hook G_Zola General .NET 2 May 15th, 2005 08:11 PM
Internet Events Hook SpyEyes Pro VB 6 0 December 15th, 2004 06:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.