Re: IStream.Read()
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 9 May 2007 12:33:00 -0400
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.
.
- Follow-Ups:
- Re: IStream.Read()
- From: Willy Denoyette [MVP]
- Re: IStream.Read()
- References:
- IStream.Read()
- From: Peter Larsen []
- Re: IStream.Read()
- From: Willy Denoyette [MVP]
- IStream.Read()
- Prev by Date: Re: Performance tuning
- Next by Date: Re: self-confidence of compiler
- Previous by thread: Re: IStream.Read()
- Next by thread: Re: IStream.Read()
- Index(es):
Relevant Pages
|