473,792 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stdout/iobuf - managed code equivalent

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?

Any pointers would be appreciated...

Many thanks,
Noel

Aug 15 '06 #1
2 2810
"no***********@ gmail.com" wrote:
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?

Any pointers would be appreciated...

Many thanks,
Noel
By common sense, stdin etc are text, not binary?

If you really need to pipeline binary objects, have look at the Monad,
aka "power shell"
http://www.microsoft.com/windowsserv...l/default.mspx

--PA
Aug 16 '06 #2

<no***********@ gmail.comwrote in message
news:11******** ************@h4 8g2000cwc.googl egroups.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

Aug 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8452
by: Paul | last post by:
I'm porting a C++ function which reads a file in binary mode, sometimes reading 2 bytes into an unsigned short, 4 bytes into a long, etc into a C# implementation. When using the FileStream.Read function, I'd like to code it to read the size of a C# ushort, for example. The documentation says the sizeof() is only supported in unsafe mode. Is there any equivalent to sizeof() that I can use in managed code?
4
1979
by: Nadav | last post by:
Hi, I hope this post will find it's way to some MS technical authority... I am experienced with bought Unmanaged C++ and Managed code ( C# ), There are some issues with the .NET framework that make me wonder... Take in mind the following points: 1. Managed objects are managed by the GC through the managed heap. 2. The GC moves the physical data representation of managed objects to
4
7182
by: repstat | last post by:
Hi I have a project which is going to be doing some string manipulation which needs to be pretty fast. The user interface is going to be written in C#. I am going to write the string handling functions in a C++ DLL. My first question is, if I insert a C++ project into my C# solution, how will VS.NET know that I want it to be unmanaged code? I intend to be calling the DLLs functions using DllImport. I've heard that you can have unmanaged...
1
2914
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code written in C#. When the app calls my unmanaged functions, they work fine. But as soon as my unmanaged functions call managed functions (in the same source file!), the app reports an "unknown exception" error.
3
1958
by: Tommy Svensson \(InfoGrafix\) | last post by:
I've been instructed to work againt a huge unmanaged C++ API from a C# application. Now, the only way, as I've understood it, is to go the Managed Extensions for C++ way. This means I have to write a wrapper between unmanaged API and my managed app. Now on to the question: If there's an unmanaged API class called X with a defined method
7
10238
by: Tim | last post by:
When there is a need to pass some dynamic information between 2 managed assemblies, the "Dictionary object" in Generic form can be used as a method parameter to pass the information. The information that needs to be passed can be stored as Key-Value pairs, and the method signature remains the same. That way, handling future requirements of passing additional details to the callee can be handled without changing the method signature. Is...
2
1414
by: Kevin Sun | last post by:
I have a problem about non-managed code and managed code.Could you like to give me some suggestion? In a non-managed MFC application project, I add some managed codes and these files are setted into /clr:oldSyntax. But the problem is that when the debug exits, the non-managed object CApplicationApp(maybe all the global and static objects)'s ~ctor is called twice. In fact the managed code only is a function without any statement and is...
5
1330
by: achutha.sridhar | last post by:
I've a pretty basic question on managed code. I read through couple of.net documentation, and reached a state where I know that managed code would be run by the .Net run time and it has so and so advanantages My question is if I've a unmanaged custom dll(say a.dll) built using VC++ 6.0 and if I were to create a wrapper class in .Net(say b.dll) to invoke the unmanaged dll, will my b.dll become a managed code or still it is unmanaged? As...
2
1958
by: ian.cross | last post by:
Hi everyone, If a multi-threaded .NET program creates a race condition updating a List (for example), could this cause a memory leak/overwritten memory/ access to another objects' private memory? Basically I'd like to know if sloppy multi-threaded code can break the CLR's guarantees of 'managed code' - garbage collection, bounds-checking, type safety etc? First time poster, long time reader - be gentle.
0
9670
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10159
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.