示例#1
0
 public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, NativeMethods.EDITSTREAM64 lParam);
        private unsafe NativeMethods.EDITSTREAM64 ConvertToEDITSTREAM64(NativeMethods.EDITSTREAM es) {
            NativeMethods.EDITSTREAM64 es64 = new NativeMethods.EDITSTREAM64();

            fixed (byte* es64p =  &es64.contents[0]) {
                byte *bp;
                long l;
                
                /*
                l = (long) es.dwCookie;
                bp = (byte *) &l;
                for (int i=0; i < sizeof(long); i++) {
                    es64.contents[i] = bp[i];
                }*/
                *((long *)es64p) = (long) es.dwCookie;
                /*
                int il = es.dwError;
                bp = (byte *) &il;
                for (int i=0; i < sizeof(int); i++) {
                    es64.contents[i+8] = bp[i];
                }*/
                *((int *)(es64p + 8)) = es.dwError;
                
                l = (long) Marshal.GetFunctionPointerForDelegate(es.pfnCallback);
                bp = (byte *) &l;
                for (int i=0; i < sizeof(long); i++) {
                    es64.contents[i+12] = bp[i];
                }
                //*((long *)(es64p + 12)) = (long) Marshal.GetFunctionPointerForDelegate(es.pfnCallback);
            }
        
            return es64;
        }