Casting IntPtr in FromRawDataApp

Aug 22, 2012 at 5:02 AM

First, I want to thank the creator(s) for this wonderful contribution.  It's always a treat to find a library that is just what you need and works well.

I have been compiling the library's source in my solution and so far, I have been using Any CPU.  On my Windows 7 x64 workstation, I've been getting (silent) overflow exceptions in KeyEventArgsExt.FromRawDataApp(), specifically, here:

#if IS_X64
            // both of these are ugly hacks. Is there a better way to convert a 64bit IntPtr to uint?

            // flags = uint.Parse(lParam.ToString());
            flags = Convert.ToUInt32(lParam.ToInt64());
            flags = (uint)lParam;

Although I am a little confused as to why the preprocessor decided that IS_X64 is false, would it be a problem to change all uint variables in this method from uint to ulong?  We could then do away with the preprocessor logic and just go with the underlined version, using a cast to ulong instead of to uint.


Nov 8, 2012 at 11:41 AM

Yeah and +1,

see my related post here