Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 C# interfacing with other programs (C)
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mirhagk




PostPosted: Sun Nov 14, 2010 11:46 pm   Post subject: C# interfacing with other programs (C)

I have code that is written in C (and am unable to port over to C# due to complexity as well as C libraries depended upon). However it is merely an interface kind of code, the backend for a project. I want to create the front end that takes information it gathers and displays it (it includes video data). I am not too familiar with C, and would VERY much like to create the front end thingy in C# (so that I can easily get the visuals working).

My only question is how do I do this. I need to write a C# program that calls functions from a C program.... I'm almost 100% I can do this, but how??? What's the easiest way?
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: Mon Nov 15, 2010 12:03 am   Post subject: Re: C# interfacing with other programs (C)

If you compile the C program to a dll, you can use the DllImport function to specify that the next method is contained within that DLL. These methods must also be declared "static" and "extern"

code:

[DllImport("myDll.dll")]
public static extern int myMethod(string param1);


You can then call the method as normal.
mirhagk




PostPosted: Mon Nov 15, 2010 8:25 am   Post subject: RE:C# interfacing with other programs (C)

okay cool, not to just figure out how to get it to be a dll (pretty sure it has a project type of that, but I think mine only has the special class library one...Sad

Thank you (this actually relates to my last post, about the kinect utility program. I want to create a C# interface to it.)
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: