QASetWindowsJournalHook by managed code



Hi All,

I am trying QASetWindowsJournalHook() in c#, it works but having some problem.

I can receive the hooked message correctly ( mouse move, click, x , y ....etc ), but as long as I do something as below, the system (ppc) will crash.

1. Run my c# QASetWindowsJournalHook application, working.
2. Click [Start], my application is still working, message received well.
3. Click [Today] or [Setup] or [IE] ... whatever the next program is .... the while system will crash ( stop there then can't do anything .... )

public static int MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam)
{
return CallNextHookEx(hHook, nCode, wParam, lParam);
}

I also tried to GCHandle everything but result is the same ...

public static void init_hook()
{
EVENTMSG myHookMessage = new EVENTMSG();
myHookMessage.message = 0;
myHookMessage.paramH = 0;
myHookMessage.time = 0;

GCHandle gc1 = GCHandle.Alloc(myHookMessage, GCHandleType.Pinned);
GCHandle gc2 = GCHandle.Alloc(MouseHookProcedure, GCHandleType.Pinned);
GCHandle gc3 = GCHandle.Alloc(hHook, GCHandleType.Pinned);

hHook = QASetWindowsJournalHook(0, MouseHookProcedure, ref myHookMessage);
}

and I also tried to package the hook functions into a c# DLL ...

but result is the same ... will also crash ...

Can somebody help ?

Appreciate!
JB

.



Relevant Pages

  • QASetWindowsJournalHook
    ... I am trying QASetWindowsJournalHook() in c#, it works but having some problem. ... I can receive the hooked message correctly, but as long as I do something as below, the system will crash. ... I also tried to GCHandle everything but result is the same ... ... EVENTMSG myHookMessage = new EVENTMSG; ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: QASetWindowsJournalHook by managed code
    ... My guess is that the gchandle is going out of scope and getting collected. ... Chris Tacke, Embedded MVP ... the while system will crash (stop there then can't do anything ... EVENTMSG myHookMessage = new EVENTMSG; ...
    (microsoft.public.dotnet.framework.compactframework)

Loading