2011-09-21 3 views
1

C#에서 "WH_JOURNALPLAYBACK"후크에 대한 콜백을 만들려고합니다. 이것은 내가 제대로 콜백을 얻을 코드C#의 WH_JOURNALPLAYBACK 후크

private delegate IntPtr JournalPlaybackProc(int nCode, IntPtr wParam, IntPtr lParam); 

private static IntPtr JournalPlaybackCallback(int nCode, IntPtr wParam, IntPtr lParam) 
{ 
     if (HC_GETNEXT == nCode && curr < EventMsgs.Count) 
     { 
      EVENTMSG hookStruct = (EVENTMSG)Marshal.PtrToStructure(lParam, typeof(EVENTMSG)); 
      EVENTMSG currentMsg = EventMsgs[curr]; 
      hookStruct.message = currentMsg.message; 
      hookStruct.paramL = currentMsg.paramL; 
      hookStruct.paramH = currentMsg.paramH; 
      hookStruct.hwnd = currentMsg.hwnd; 
      hookStruct.time = currentMsg.time; 
     } 
     if (HC_SKIP == nCode) 
     { 
      curr++; 
     } 
     if (curr == EventMsgs.Count) 
     { 
      UnhookWindowsHookEx(_journalPlaybackProcHookID); 
      _journalPlaybackProcHookID = IntPtr.Zero; 
     } 
     return CallNextHookEx(_journalPlaybackProcHookID, nCode, wParam, lParam); 
} 

이다, 나는 이벤트를 재생 내 데이터의 lParam의 값을 수정해야 가정합니다. 어떻게해야합니까?

+0

나는 또한 동일한 문제가 있습니다. 값을 잘 기록 할 수는 있지만 재생이 번거로울 수 있습니다. 해결책을 찾았습니까? – Kelly

답변

0

난 당신이

Marshal.StructureToPtr (사실 hookStruct, lParam에)가 필요합니다 가정;

어느 시점에서 다시 작성하십시오. 내가 달릴 때 그것은 단지 매달린다.