It is a process of I use the SetWindowsHookEx install hooks, check a lot of information, said can't install global hooks, install hooks all unsuccessful (0), in my post [https://bbs.csdn.net/topics/396175597] it is suggested that using easyhook, all in this post, please win copydate example,
Public class CopyDataHook {
Private const int WM_COPYDATA=https://bbs.csdn.net/topics/0x004A;
Private IntPtr nextHookPtr;
Private HookProc HookProc;
Private const int HookType. CallWndProc=4;
[DllImport (" User32. DLL)]
Public static extern void UnhookWindowsHookEx (IntPtr handle);
[DllImport (" User32. DLL)]
Public static extern IntPtr SetWindowsHookEx (int idHook, [MarshalAs (UnmanagedType. FunctionPtr)] HookProc LPFN, IntPtr hinstance, int threadID); .
[DllImport (" User32. DLL)]
Public static extern IntPtr CallNextHookEx (IntPtr handle, int code, IntPtr wparam, IntPtr lparam);
Public CopyDataHook ()
{
NextHookPtr=IntPtr. Zero;
}
Public void SetCopyDataHook ()
{
If (nextHookPtr!=IntPtr. Zero)
return;
HookProc=new hookProc (CopyDatahookProc);
NextHookPtr=SetWindowsHookEx ((int) HookType CallWndProc,
HookProc,
Marshal. GetHINSTANCE (
The Assembly. GetExecutingAssembly (.) GetModules () [0]),
0);
Console. Write (string Format (" HookPtr: {0} ", nextHookPtr. ToString ()));
}
}
CodePudding user response:
Can install global hooks (hook function in the DLL (dynamic link libraries of c/c + +)),Dynamic libraries of c # and c/c + +, so can only use local hooks
MSDN, very comprehensive, or you will write a friend help you write good, direct call you, is not the same
CodePudding user response: