public class MsgEventArgs: EventArgs
{
public int hWnd;
public int uMsg;
public int wParam;
public int lParam;
public MsgEventArgs(int hWnd, int uMsg, int wParam, int lParam)
{
this.hWnd = hWnd;
this.uMsg = uMsg;
this.wParam = wParam;
this.lParam = lParam;
}
}
class HookMessage
{
const int GWL_WNDPROC= -4;
private int pPrevProc, hWnd;
delegate int MyCallBack(int hWnd, int message, int wParam, int lParam);
[DllImport("User32.dll"]
public static extern int SetWindowLong(int hWnd, int nIndex, int newLong);
[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern int CallWindowProc (int pPrevProc, int hWnd, int message,int wParam,int lParam);
public event MsgEventHandler OnMessage;
public HookMessage(int wHandle)
{
hWnd = wHandle;
MyCallBack wndProc= new MyCallBack(WindowProc);
pPrevProc = SetWindowLong(hWnd, GWL_WNDPROC, (int)wndProc);
}
OK, maybe I need to understand why you're trying to do this. If you're trying to hook another processes window messages, that requires a system-wide hook, which isn't really recommended.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.