I need to pass an IntPtr to IStream.Read, and the IntPtr should point to a ulong variable. How do I get this IntPtr that points to my ulong variable?
The best way is to change the IStream definition:
void Read([Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pv,
int cb, /*IntPtr*/ ref int pcbRead);
Then you can write
int pcbRead = 0;
Read(..., ref pcbRead);