示例#1
0
        /// <summary>
        ///  Read the data into the given buffer
        /// </summary>
        /// <param name="buffer">The buffer receiving the data</param>
        /// <returns>The number of bytes read</returns>
        public unsafe override int Read(Span <byte> buffer)
        {
            uint bytesRead = 0;

            if (!buffer.IsEmpty)
            {
                fixed(byte *ch = &buffer[0])
                {
                    comStream.Read(ch, (uint)buffer.Length, &bytesRead);
                }
            }

            return((int)bytesRead);
        }
 private static int Read(IntPtr thisPtr, byte *pv, uint cb, uint *pcbRead)
 {
     try
     {
         Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr);
         instance.Read(pv, cb, pcbRead);
         return(S_OK);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
         return(ex.HResult);
     }
 }
示例#3
0
            private static int Read(IntPtr thisPtr, byte *pv, uint cb, uint *pcbRead)
            {
                try
                {
                    Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr);
                    inst.Read(pv, cb, pcbRead);
                }
                catch (Exception e)
                {
                    return(e.HResult);
                }

                return(S_OK);
            }