The Binary_r structure encodes an array of un-interpreted bytes.
示例#1
0
        /// <summary>
        /// Parse Binary_r structure.
        /// </summary>
        /// <param name="ptr">A pointer points to memory allocated.</param>
        /// <returns>Instance of Binary_r structure.</returns>
        public static Binary_r ParseBinary_r(IntPtr ptr)
        {
            Binary_r b_r = new Binary_r
            {
                Cb = (uint)Marshal.ReadInt32(ptr)
            };

            if (b_r.Cb == 0)
            {
                b_r.Lpb = null;
            }
            else
            {
                b_r.Lpb = new byte[b_r.Cb];
                IntPtr baddr = new IntPtr(Marshal.ReadInt32(ptr, sizeof(uint)));
                for (uint i = 0; i < b_r.Cb; i++)
                {
                    b_r.Lpb[i] = Marshal.ReadByte(baddr, (int)i);
                }
            }

            return(b_r);
        }
        /// <summary>
        /// Parse Binary_r structure.
        /// </summary>
        /// <param name="ptr">A pointer points to the allocated memory.</param>
        /// <returns>Instance of Binary_r structure.</returns>
        public static Binary_r ParseBinary_r(IntPtr ptr)
        {
            Binary_r b_r = new Binary_r
            {
                Cb = (uint)Marshal.ReadInt32(ptr)
            };

            if (b_r.Cb == 0)
            {
                b_r.Lpb = null;
            }
            else
            {
                b_r.Lpb = new byte[b_r.Cb];
                if (AdapterHelper.Transport.ToLower(System.Globalization.CultureInfo.CurrentCulture) != "mapi_http")
                {
                    IntPtr baddr = new IntPtr(Marshal.ReadInt32(ptr, sizeof(uint)));
                    for (uint i = 0; i < b_r.Cb; i++)
                    {
                        b_r.Lpb[i] = Marshal.ReadByte(baddr, (int)i);
                    }
                }
                else
                {
                    for (uint i = 0; i < b_r.Cb; i++)
                    {
                        b_r.Lpb[i] = Marshal.ReadByte(ptr, (int)i + sizeof(uint));
                    }
                }
            }

            return b_r;
        }