How can I use C++ codes with .NET Framework codes?

A

Allen Maki

I would be pleased if someone gives me a general idea; how I am going to do
this. I am using visual C++ .NET 2003.



I made a simple program using conventional C++ code. This program accepts
data from the user, does some calculations and outputs the result back to
the user using the console.



Now, I want to use the .NET Framework to interact with the user through
Forms, Dialog Boxes and Controls.



I managed to create all the forms that I need to interact with the user and
they work very well together. But, now I want to use the first program that
I made from conventional C++ with .NET Framework. In other words I want the
user to input data (through Forms and controls) and then I want to
manipulate the data mathematically (using the conventional C++ code) and out
put the result (through other Forms and controls).



So my question is how can I use the conventional C++ code with the managed
code and which file(s) am I going to use? For example, I have the following
files:-



References:

...

...

Source Files:

AssemblyInfo.cpp

Form1.cpp

Form2.cpp

Form3.cpp

Stdafx.cpp



Header Files:

Form1.h

Form2.h

Form3.h

Resource.h

Stdafx.h



Resource Files:

...

...

...

ReadMe.txt



Allen
 
M

Michael C

Allen Maki said:
Now, I want to use the .NET Framework to interact with the user through
Forms, Dialog Boxes and Controls.

There's several ways. The first is to use the Process namespace to redirect
the output of your console app. This is not ideal as you need to interpret
the command line results. The second is to make the plain C++ code into a
dll and call it using the System.Runtime.InteropServices namespace. The last
is to recompile it as a dot net dll and add it as a reference. This last 1
is very easy to do as I'm not a C++ programmer and managed to do it (there
is a wixard to help you out).
 
A

Allen Maki

Thanks Michael,

I did not know what is wixard?

where am I going to write the code. Which files of the ones below am I
going to use?
 
M

Michael C

Allen Maki said:
Thanks Michael,

I did not know what is wixard?

Sorry, i meant Wizard. It's all fairly simple, you just create new project
for dot net dll and follow the steps.
where am I going to write the code. Which files of the ones below am I
going to use?

I really don't know it that well but once you create your dll there is
another wizard to add classes and functions, just add your code to one of
the functions. Is there a reason you're using C instead of C#?

Michael
 

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