示例#1
0
        /// <summary>
        ///  Initializes a new instance of the MAPIProp class.
        /// </summary>
        /// <param name="prop">pSPropValue structure</param>
        internal MAPIProp(SPropValue prop)
        {
            this.tag = prop.ulPropTag;
            switch ((PT)((uint)this.tag & 0xFFFF))
            {
            case PT.PT_TSTRING:
                this.t   = typeof(string);
                this.str = Marshal.PtrToStringUni(prop.Value.lpszW);
                break;

            case PT.PT_STRING8:
                this.t   = typeof(string);
                this.str = Marshal.PtrToStringAnsi(prop.Value.lpszA);
                break;

            case PT.PT_LONG:
            case PT.PT_I2:
            case PT.PT_BOOLEAN:
                this.t  = typeof(int);
                this.ul = prop.Value.ul;
                break;

            case PT.PT_BINARY:
                this.t      = typeof(Byte[]);
                this.binary = prop.Value.bin.AsBytes;
                break;

            case PT.PT_SYSTIME:
                this.t    = typeof(DateTime);
                this.p_li = prop.Value.li;
                break;

            case PT.PT_I8:
                this.t    = typeof(UInt64);
                this.p_li = prop.Value.li;
                break;

            default:
                this.t = null;
                break;
            }
        }
示例#2
0
        /// <summary>
        /// Returns one or more rows from a table, beginning at the current cursor position.
        /// </summary>
        /// <param name="lRowCount">Maximum number of rows to be returned.</param>
        /// <param name="sRows">an SRow array holding the table rows.</param>
        /// <returns></returns>
        public bool QueryRows(int lRowCount, out SRow[] sRows)
        {
            IntPtr  pRowSet = IntPtr.Zero;
            HRESULT hr      = tb_.QueryRows(lRowCount, 0, out pRowSet);

            if (hr != HRESULT.S_OK)
            {
                MAPINative.MAPIFreeBuffer(pRowSet);
            }

            uint cRows = (uint)Marshal.ReadInt32(pRowSet);

            sRows = new SRow[cRows];

            if (cRows < 1)
            {
                MAPINative.MAPIFreeBuffer(pRowSet);
                return(false);
            }

            int    pIntSize = IntPtr.Size, intSize = Marshal.SizeOf(typeof(Int32));
            int    sizeOfSRow = 2 * intSize + pIntSize;
            IntPtr rows       = pRowSet + intSize;

            for (int i = 0; i < cRows; i++)
            {
                IntPtr pRowOffset = rows + i * sizeOfSRow;
                uint   cValues    = (uint)Marshal.ReadInt32(pRowOffset + pIntSize);
                IntPtr pProps     = Marshal.ReadIntPtr(pRowOffset + pIntSize + intSize);

                IPropValue[] lpProps = new IPropValue[cValues];
                for (int j = 0; j < cValues; j++) // each column
                {
                    SPropValue lpProp = (SPropValue)Marshal.PtrToStructure(pProps + j * Marshal.SizeOf(typeof(SPropValue)), typeof(SPropValue));
                    lpProps[j] = new MAPIProp(lpProp);
                }
                sRows[i].propVals = lpProps;
            }
            MAPINative.MAPIFreeBuffer(pRowSet);
            return(true);
        }
示例#3
0
 /// <summary>
 ///  Initializes a new instance of the MAPIProp class.
 /// </summary>
 /// <param name="prop">pSPropValue structure</param>
 internal MAPIProp(SPropValue prop)
 {
     this.tag = prop.ulPropTag;
     switch ((PT)((uint)this.tag & 0xFFFF))
     {
         case PT.PT_TSTRING:
             this.t = typeof(string);
             this.str = Marshal.PtrToStringUni(prop.Value.lpszW);
             break;
         case PT.PT_STRING8:
             this.t = typeof(string);
             this.str = Marshal.PtrToStringAnsi(prop.Value.lpszA);
             break;
         case PT.PT_LONG:
         case PT.PT_I2:
         case PT.PT_BOOLEAN:
             this.t = typeof(int);
             this.ul = prop.Value.ul;
             break;
         case PT.PT_BINARY:
             this.t = typeof(Byte[]);
             this.binary = prop.Value.bin.AsBytes;
             break;
         case PT.PT_SYSTIME:
             this.t = typeof(DateTime);
             this.p_li = prop.Value.li;
             break;
         case PT.PT_I8:
             this.t = typeof(UInt64);
             this.p_li = prop.Value.li;
             break;
         default:
             this.t = null;
             break;
     }
 }