void _SetHook(int i, AccEVENT eMin, AccEVENT eMax, int idProcess, int idThread, AccHookFlags flags) { if (eMin == 0) { return; } if (eMax == 0) { eMax = eMin; } var hh = Api.SetWinEventHook(eMin, eMax, default, _proc1, idProcess, idThread, flags);
/// <summary> /// Sets a hook for an event or a range of events. /// </summary> /// <exception cref="InvalidOperationException">Hooks are already set and <see cref="Unhook"/> not called.</exception> /// <remarks> /// Parameters are the same as of the constructor, but values can be different. /// </remarks> public void Hook(AccEVENT eventMin, AccEVENT eventMax = 0, int idProcess = 0, int idThread = 0, AccHookFlags flags = 0) { _Throw1(); _a = new IntPtr[1]; _SetHook(0, eventMin, eventMax, idProcess, idThread, flags); }
Action <HookData.AccHookData> _proc2; //caller's hook proc /// <summary> /// Sets a hook for an event or a range of events. /// </summary> /// <param name="eventMin">The lowest event constant value in the range of events. Can be AccEVENT.MIN to indicate the lowest possible event value. Events reference: <msdn>SetWinEventHook</msdn>. Value 0 is ignored.</param> /// <param name="eventMax">The highest event constant value in the range of events. Can be AccEVENT.MAX to indicate the highest possible event value. If 0, uses <i>eventMin</i>.</param> /// <param name="hookProc">The hook procedure (function that handles hook events).</param> /// <param name="idProcess">The id of the process from which the hook function receives events. If 0 - all processes on the current desktop.</param> /// <param name="idThread">The native id of the thread from which the hook function receives events. If 0 - all threads.</param> /// <param name="flags"></param> /// <exception cref="AuException">Failed.</exception> /// <example>See <see cref="AHookAcc"/>.</example> public AHookAcc(AccEVENT eventMin, AccEVENT eventMax, Action <HookData.AccHookData> hookProc, int idProcess = 0, int idThread = 0, AccHookFlags flags = 0) { _proc1 = _HookProc; Hook(eventMin, eventMax, idProcess, idThread, flags); _proc2 = hookProc; }