473,811 Members | 3,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using old header files (*.h) in c#

Hi all,
I received a number of header files of several years old in C , now I want
to use this code in c#. What are the steps I need to make? Can I compile it
into a DLL with c++ and use it in c# somehow(.net 2005) ? must I convert it
to cs files ? Is there a tool available ? Maybe examples ?
Many many and even more thanks,
--
Lu
Feb 23 '06 #1
2 2228
sounds easy .. I only have about 20 header files , some headers include the
others, .........how do I get the header files compiled correctly into .dll
s. The P/invoke transforms the .h to code with a lot of .dlls imported. But
then I have to create dll's out of these header files....how do I do that.

sorry but I'm not a c guru....anywhay thanks for yr help.
--
Lu
"Vadym Stetsyak" wrote:
Hello, Lu!

LP> Hi all,
LP> I received a number of header files of several years old in C , now I
LP> want to use this code in c#. What are the steps I need to make? Can I
LP> compile it into a DLL with c++ and use it in c# somehow(.net 2005) ?
LP> must I convert it to cs files ? Is there a tool available ? Maybe
LP> examples ? Many many and even more thanks,

What are there in headers? usually there are placed some definitions and declarations ( function prototypes, constants etc ). If you have headers, then it seems that you also have the code that uses these headers.

IMO here you have following ways:
- compile the code C with headers into separate DLL, ensuring that declared functions are exported from that dll. Then in the managed code ( C# ) you can use them via p/invoke.

- rewrite the code totally in C#.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot

Feb 24 '06 #2
Hello, Lu!

LP> sounds easy .. I only have about 20 header files , some headers include
LP> the others, .........how do I get the header files compiled correctly
LP> into .dll s.

What do your header files contain? only definitions .
To compile to dll you have to use compiler and linker. Or if you have Visual Studio then you can create Dll project and include there all the sources you have

P.S. P/Invoke is not transforming files. It enables you to call unmanaged functions from managed environment.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 24 '06 #3

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

Similar topics

6
2357
by: Eric Ellsworth | last post by:
Hi, I've been wrestling for several months now with this issue in IE: http://support.microsoft.com/?kbid=308090 (IE thinks that ZIPs sent from a script are corrupt when they are not). IE now also seems to think that many other files are ActiveX controls and pops up the "Some files may damage your computer...Open Save Cancel" dialog. However, I am quite certain that others have managed to use a script
16
12551
by: matthurne | last post by:
I just started learning C++ on my own...I'm using Accelerated C++. Something it hasn't explained and I keep wondering about is how header files actually work. I suspect it doesn't get into it because it is, as the authors love to say, "implementation specific". If that's the case, how does the compiler commonly handle them? I use Linux and gcc specifically. Basically, I don't understand how a header file being included makes a...
13
141273
by: Squid Seven | last post by:
This is just bizarre. for the following snippet of code: #include <string> using std::string; I get the error message:
0
2026
by: Richard Taylor | last post by:
User-Agent: OSXnews 2.07 Xref: number1.nntp.dca.giganews.com comp.lang.python:437315 Hi I am trying to use py2app (http://undefined.org/python/) to package a gnome-python application called gramps (http://www.gramps-project.org) for MAC OS X.
18
2757
by: John Smith | last post by:
Hi all What does the group think of the practise of including one header file from inside another? I have some legacy code where this has been done, and it creates a dependency on a module (collection of files) which are not required, except for one header file's contents. I'd say 'No, header files should be included in the C source, not in another
1
2764
by: Xiangliang Meng | last post by:
Hi, all. Recently, I find there is a way in our project to maintain a global set in many files by using preprocessing directives. I'm wondering if we could find a better method for this. Many colors are referred in different subsystems in our projects. They are defined as enumeration constants and a single color must be the same value all across our projects.
5
6782
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would cause. If I could create a large file that could be encrypted, and maybe add files to it by appending them and putting in some kind of delimiter between files, maybe a homemade version of truecrypt could be constructed. Any idea what it...
21
34454
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
221
367782
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files. ...
0
9730
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...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
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...
0
6893
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
5555
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
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
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
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.