Hi,
it is more likely that you want to pass the streams content
to the API call. You did not name the API Function but
i guess it expects just a bunch of memory or a pointer
so this might work for you:
//CODE
byte[] byteMemoryFromSream; //will hold stream bytes
MemoryStream ms = new MemoryStream(255); //memory stream with 255 bytes
content, here comes our stream into play
byteMemoryFromSream = new byte[ms.Length]; //reserve bytes of size
ms.lengtht (255)
IntPtr ptrMemoryStreamContent = Marshal.AllocHGlobal((int)ms.Length);
//allocate memory from heap
Marshal.Copy(byteMemoryFromSream, 0, ptrMemoryStreamContent,
(int)ms.Length);
//YourApiCall(ptrMemoryStreamContent); //passing memory pointer to the API
call
Marshal.FreeHGlobal(ptrMemoryStreamContent);//release memory from heap
//CODE END
To make sure this works, use exception handling and parameter checking
for invalid or null types,...
Regards
Kerem
--