Is there anything LINQ can't do?
var arg
= Expression
.Parameter( typeof( WindowHookProc
),
"arg" );
acedRegisterFilterWinMsg =
Expression.Lambda<Func<WindowHookProc, int>>(
Expression.Call( target, arg ), arg ).Compile();
Brilliant solution. It's kinda like when I flew a helicopter - I see what you did there, I can follow how it works, I know I can go through the motions and keep it in the air but I also know I need to understand it properly because it is a very big fan, if you know what I mean.
/// ...(same must be done for acedRemoveFilterWinMsg, but that's not shown here):
You always let go of the cyclic while we're in flight. That's a good teaching technique and I like it - I'll never learn to fly properly if I don't need to. I'll try not to crash and burn. No matter, the Visual Studio debugger is a lot more forgiving than gravity.
In plain English, in case my analogy is clearer in my head than yours, dear reader, I like an answer that says "the answer is this way, go find it" and most of Tony's answers tend to do thhat, in case you hadn't noticed. If that annoys you then I don't care. Control-V and a crossed-fingers stab at F5 just doesn't do it for me. I'd rather learn how to fish. I'd rather know what it is that I don't know. Awesome is a valid aspiration, although its attainability can, unfortunately, be variable.
C# Expression Trees happened during that 20-year break I had from coding (yes I did, seriously; no, I don't recommended it) so I'm not up to speed with that that bit of LINQ yet. For those who don't even know where to start with them, try
http://msdn.microsoft.com/en-us/library/bb397951.aspx and/or
http://pluralsight.com/training/Courses/TableOfContents/linq-fundamentals (and others) and/or spend a night / week with Google,
http://StackOverflow.com and caffeine. Lots of all of those. I'll see you there.
.
For those of us who look at TT's answers and think
"Dammit! I will never be that good at this." - welcome to the club. See also
Jon Skeet. We may be right to varying degrees but that's no excuse for not striving to be these best you can be at this, or at least better than you were yesterday. Don't let the presence of brilliant minds (there are a few around here) scare you into silence - you won't learn anything if you don't make a dill of yourself once every now and then. I'm a voracious learner, as you may have seen from time to time.
Thanks for this and every other answer Tony, and others.