The StringArray_r structure encodes an array of references to 8-bit character strings.
예제 #1
0
        /// <summary>
        /// Parse StringArray_r structure.
        /// </summary>
        /// <param name="ptr">A pointer points to memory allocated.</param>
        /// <returns>Instance of StringArray_r structure.</returns>
        public static StringArray_r ParseStringArray_r(IntPtr ptr)
        {
            StringArray_r stringArray = new StringArray_r
            {
                Values = (uint)Marshal.ReadInt32(ptr)
            };

            if (stringArray.Values == 0)
            {
                stringArray.LppszA = null;
            }
            else
            {
                stringArray.LppszA = new string[stringArray.Values];
                IntPtr szaddr = new IntPtr(Marshal.ReadInt32(ptr, sizeof(uint)));
                int    offset = 0;
                for (uint i = 0; i < stringArray.Values; i++)
                {
                    stringArray.LppszA[i] = Marshal.PtrToStringAnsi(new IntPtr(Marshal.ReadInt32(szaddr, offset)));
                    offset += 4;
                }
            }

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

            if (stringArray.CValues == 0)
            {
                stringArray.LppszA = null;
            }
            else
            {
                if (AdapterHelper.Transport.ToLower(System.Globalization.CultureInfo.CurrentCulture) != "mapi_http")
                {
                    IntPtr szaddr = new IntPtr(Marshal.ReadInt32(ptr, sizeof(uint)));
                    stringArray.LppszA = new string[stringArray.CValues];
                    int offset = 0;
                    for (uint i = 0; i < stringArray.CValues; i++)
                    {
                        stringArray.LppszA[i] = Marshal.PtrToStringAnsi(new IntPtr(Marshal.ReadInt32(szaddr, offset)));
                        offset += 4;
                    }
                }
                else
                {
                    stringArray.LppszA = new string[stringArray.CValues];
                    for (uint i = 0; i < stringArray.CValues; i++)
                    {
                        stringArray.LppszA[i] = BitConverter.ToString(ParseString_r(ptr));
                    }
                }
            }

            return stringArray;
        }