Can I include .C & .H file in C# project?

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

I have a DOS application done in MS C++ 6.0 that was written in C. Since
it's DOS, I'm creating a GUI for the application in C# but would like to use
all the original functions from the .C and .H files. Can I include these in
my C# project or do I need to modify them? They're about 10,000 lines of
code.

Thanks.
 
Jim said:
I have a DOS application done in MS C++ 6.0 that was written in C. Since
it's DOS, I'm creating a GUI for the application in C# but would like to use
all the original functions from the .C and .H files. Can I include these in
my C# project or do I need to modify them? They're about 10,000 lines of
code.

You can absolutly in clude .c and .h files in your project.

You can just not to anything meaningfull with them. You can just have them
sitting in the project, with the compiler neve rseeing them, or including
them as ressources (files go into the DLL).

But the compiler does not know how to handle .c and .h files. The are C, not
C#.

You need a separate projet that is C++ and then you compile them in to a DLL
and use dllimport to access the methods. Not sur eit is wise, though.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
 
Hi Jim,

You cannot include these files in your .net project, you can do one of two
things:
1- Create a DLL from those files and later you can call this dll from the
..net app
2- if you know C++ you can try to convert/reuse then directly in a managed
C++ dll that your c# app can call directly.


Hope this help,
 
Back
Top