how to get a pointer to a Stream?

A

Assido

Hello @all,

can someone tell me how to get a pointer to a stream?
I need to pass the pointer to an API-Functioncall.

Thanks for any help!
 
A

Armin Zingler

Assido said:
Hello @all,

can someone tell me how to get a pointer to a stream? I need to pass
the pointer to an API-Functioncall.

Does the API function know what a .Net IO.Stream is? Haven't had it at
all yet. Declaring the argument "byval bla as io.stream" and passing "x"
(x being declared As IO.Stream) would do the job. But I have doubts that
a stream is a stream.


Armin
 
H

Herfried K. Wagner [MVP]

Assido said:
can someone tell me how to get a pointer to a stream?
I need to pass the pointer to an API-Functioncall.

Could you post the API function's prototype?

If you are referring to the file's handle, take a look at the 'FileStream'
object's 'Handle' property.
 
A

Assido

Hello Herfried,

here is the API-Function:

Declare Function WrapCompressedRTFStream Lib "mapi32.dll" (ByRef
lpCompressedRTFStream As Long, ByVal ulFlags As Long, ByRef
lpUncompressedRTFStream As Long) As Long
 
H

Herfried K. Wagner [MVP]

Assido said:
here is the API-Function:

Declare Function WrapCompressedRTFStream Lib "mapi32.dll" (ByRef
lpCompressedRTFStream As Long, ByVal ulFlags As Long, ByRef
lpUncompressedRTFStream As Long) As Long

You may want to wrap the stream into a
'System.Runtime.InteropServices.ComTypes.IStream' and declare the parameter
as 'ByVal ... As IStream'. However, note that your declaration is not valid
for VB.NET.

Untested:

\\\
Imports System.Runtime.InteropServices
Imports System.Runtime.InteropServices.ComTypes
....
Public Declare Function WrapCompressedRTFStream Lib "mapi32.dll" ( _
ByVal lpCompressedRTFStream As IStream, _
ByVal ulflags As UInt32, _
<Out()> ByVal lpUncompressedRTFStream As IStream _
) As IntPtr
///

Maybe you have to specify additional marshalling attributes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top