<no***********@gmail.comwrote in message
news:11********************@h48g2000cwc.googlegrou ps.com...
Hi,
I am porting a C++ console application to managed C++ dll - for now
basically wrapping it in a class. The console app has the option to
write to a file or stdout using fwrite.
So, how do I bridge the managed gap? I really want to be able to pass
a BinaryStream to the managed C++ code from the calling C# code...can
this be done, and how do I go about modifying the C++ code to handle
it?
If it's determined to use fwrite, then you will have to capture the data
with a pipe. A combination of _pipe, _fdopen will give you a FILE* that the
existing code can fwrite to. Then you can either wrap the other end of the
pipe in a BinaryStream and give that to your C# code, or else read from the
pipe, writing into the BinaryStream provided by the C# code.
But fwrite's interface is so simple, you should probably just
#define fwrite streamwrite
and write your own size_t streamwrite( const void * buffer, size_t size,
size_t count, FILE * stream ) function that puts the data where you want it.
>
Any pointers would be appreciated...
Many thanks,
Noel