Re: IStream.Read()



Read allows the last pointer passed in to be null. From the
documentation for IStream from the Platform SDK:

pcbRead
[out] A pointer to a ULONG variable that receives the actual number of bytes
read from the stream object.
You can set this pointer to NULL. In this case, this method does not
return the number of bytes read.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx> wrote in message
news:EEC74A62-20DB-4AB9-986E-F2AEBF6FFF2C@xxxxxxxxxxxxxxxx
"Peter Larsen []" <PeterLarsen@xxxxxxxxxxxxxxxx> wrote in message
news:ujiHx%23jkHHA.1216@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I have a problem using System.Runtime.InteropServices.ComTypes.IStream.

Sample using the Read() method:

if (IStreamObject != null)
{
IntPtr readBytes = IntPtr.Zero;
IStreamObject.Read(buffer, size, readBytes);
Result = readBytes.ToInt32();
}

The above code read data from a stream into a buffer. This works - the
buffer is filled with valid data.
The problem is that the number of bytes read (in readBytes) is always
zero.

How am i suppose to know whether the call failed or not, if i dont have
the number of bytes read ?

BR
Peter


What you are passing as third argument is wrong, you are passing a null
pointer, while the function expects a pointer to an int.
I would expect this to throw an exception, as the underlying COM method
should check all pointers on validity and return an HRESULT =
STG_E_INVALIDPOINTER when one of them is null.
From what stream are you actually reading?

WIlly.



.



Relevant Pages

  • Re: std::cin and disabling canonical line processing (buffering)
    ... Your answer tells me how to deal with it if the istream pointer is cin. ... > Harold Bamford wrote: ...
    (microsoft.public.vc.stl)
  • Re: sanity check
    ... Brian, there's no object passing here - just interface pointers. ... if the client uses IStream after the call ... > The server essentially gets a copy of the IStream pointer. ...
    (microsoft.public.win32.programmer.ole)
  • Re: Returning IStream as IDisPatch causes crash in VB?
    ... Any way you look at it, a pointer to IDispatch is not the same as a pointer ... IStream interface doesn't match what it's expecting, ...
    (microsoft.public.vc.atl)
  • Re: Returning IStream as IDisPatch causes crash in VB?
    ... Do you mean write another Object that wraps my IStream? ... > Any way you look at it, a pointer to IDispatch is not the same as a ... > IDispatch or IUnknown, and call it, but the signature available in the ... > IStream interface doesn't match what it's expecting, ...
    (microsoft.public.vc.atl)
  • Re: Passing Stream object by reference
    ... I then want to pass that stream to another function to perform ... > My GetMP3Data function accepts a pointer to a stream as its arguement. ... I wonder where the reference is that you have been talking about at the ...
    (comp.lang.cpp)