Board index » cppbuilder » export an TMemoryStream in an automation object

export an TMemoryStream in an automation object


2005-05-24 05:33:14 PM
cppbuilder2
Hi,
I have created an automation object around my executable, so it's an
out-proc server.
In the typelibrary i want to create a method 'HResult GetData(??Type??
DataStream)'
What type do I need. I read a lot on IStream and TStreamAdapter on the
internet, but i cannot select the IStream type in the type-library parameter
editor?!
The actual problem is that i don't know how to transport an TMemoryStream
over the COM-layer that correctly marshall's the stream.
Can anyone help me, or tell me where i can get a good example?
Thanx in advance, Jos Hermans.
ps: I'm using Builder 6.0, windows 2000
 
 

Re:export an TMemoryStream in an automation object

"Jos Hermans" < XXXX@XXXXX.COM >wrote in message
Quote
I read a lot on IStream and TStreamAdapter on the internet, but
i cannot select the IStream type in the type-library parameter editor?!
That is a limitation in Borland's implementation of the Type Library. You
are not alone, many people have complained about this very issue in the
past. Declare your parameter as IUnknown instead, and then call
QueryInterface() inside of your method to obtain the IStream interface
manually. You will still be able to pass an IStream directly to the method
when calling it, as IStream derives from IUnknown.
Quote
The actual problem is that i don't know how to transport an
TMemoryStream over the COM-layer that correctly marshall's
the stream.
IStream/TStreamAdapter is one way to do that. An alternative is to use a
VARIANT that contains a SAFEARRAY of the stream's bytes rather than the
stream itself.
Gambit