The WStringArray_r structure encodes an array of references to Unicode strings.
Exemple #1
0
        /// <summary>
        /// Parse WStringArray_r structure.
        /// </summary>
        /// <param name="ptr">A pointer points to memory allocated.</param>
        /// <returns>Instance of WStringArray_r structure.</returns>
        public static WStringArray_r ParseWStringArray_r(IntPtr ptr)
        {
            WStringArray_r wsa_r = new WStringArray_r
            {
                Values = (uint)Marshal.ReadInt32(ptr)
            };

            if (wsa_r.Values == 0)
            {
                wsa_r.LppszW = null;
            }
            else
            {
                wsa_r.LppszW = new string[wsa_r.Values];
                IntPtr szwaddr = new IntPtr(Marshal.ReadInt32(ptr, sizeof(uint)));
                for (uint i = 0; i < wsa_r.Values; i++)
                {
                    wsa_r.LppszW[i] = Marshal.PtrToStringUni(new IntPtr(Marshal.ReadInt32(szwaddr)));
                    szwaddr         = new IntPtr(szwaddr.ToInt32() + 4);
                }
            }

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

            if (wsa_r.CValues == 0)
            {
                wsa_r.LppszW = null;
            }
            else
            {
                if (AdapterHelper.Transport.ToLower(System.Globalization.CultureInfo.CurrentCulture) != "mapi_http")
                {
                    IntPtr szwaddr = new IntPtr(Marshal.ReadInt32(ptr, sizeof(uint)));
                    wsa_r.LppszW = new string[wsa_r.CValues];
                    for (uint i = 0; i < wsa_r.CValues; i++)
                    {
                        wsa_r.LppszW[i] = Marshal.PtrToStringUni(new IntPtr(Marshal.ReadInt32(szwaddr)));
                        szwaddr = new IntPtr(szwaddr.ToInt32() + 4);
                    }
                }
                else
                {
                    wsa_r.LppszW = new string[wsa_r.CValues];
                    for (uint i = 0; i < wsa_r.CValues; i++)
                    {
                        wsa_r.LppszW[i] = BitConverter.ToString(ParseWString_r(ptr));
                    }
                }
            }

            return wsa_r;
        }