|
-
August 1st, 2007, 05:25 PM
#1
Help - Low Level CBTProc Hook
Is it possible to create a low level hook of the CBTProc Function (so that I can detect when an external window is minimized, etc)? If it's possible, how would I go about doing it?
Thanks in advanced!
-Eric
-
August 1st, 2007, 06:45 PM
#2
Re: Help - Low Level CBTProc Hook
Windows hooks aren't the easiest thing to accomplish.
You will need to import some win32 functions, and do a google search on how to implement them for your desired methods.
SetWindowsHookEx
UnhookWindowsHookEx
CallNextHookEx
Code:
[DllImport("user32.dll", CharSet = CharSet.Auto,
CallingConvention = CallingConvention.StdCall)]
public static extern int SetWindowsHookEx(int idHook, HookProc lpfn,
IntPtr hInstance, int threadId);
[DllImport("user32.dll", CharSet = CharSet.Auto,
CallingConvention = CallingConvention.StdCall)]
public static extern bool UnhookWindowsHookEx(int idHook);
[DllImport("user32.dll", CharSet = CharSet.Auto,
CallingConvention = CallingConvention.StdCall)]
public static extern int CallNextHookEx(int idHook, int nCode,
Int32 wParam, IntPtr lParam);
-
August 2nd, 2007, 01:06 AM
#3
Re: Help - Low Level CBTProc Hook
The problem I'm running into is that it seems that hooking using the WH_CBT event with SetWindowsHookEx() will only apply to the current process, and does not seem to apply to external applications even when set up like a global hook. Is there any other way besides using the CBT hook that would allow me to be able to detect when any window is minimized?
-
August 3rd, 2007, 02:28 AM
#4
Re: Help - Low Level CBTProc Hook
This is an old post I made for VB 6 but I think it still holds true for C# RegisterShellHook
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|