C# with C++ Functions - Learn How to Link Together

  • Context: C/C++ 
  • Thread starter Thread starter CFDFEAGURU
  • Start date Start date
  • Tags Tags
    C++ Functions
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
CFDFEAGURU
Messages
781
Reaction score
10
Hello all,

All of my C++ programming experience is in the coding of console applications and I have recently been asked to re-code some of my console applications as windows forms applications. I asked two highly experienced programmers (one a physicist and the other a financial/business relations expert) about C++ for windows forms applications and they told me never to use C++ for windows forms applications. The main reason being, simply too much time and complexity.

However, they did instruct me to use C# for the windows forms and link the needed C++ functions. Neither of them directed me as to how you link the C++ functions to the C# forms.

I have a good deal of experience with forms, controls, and events in VBA for Excel and Access so I am not totally green with form applications.

So I have two questions;

1. Are they correct about "never use C++ for windows form applications"?

2. Does anyone have a simple example of how to link the two languages together?

Thanks
Matt
 
Physics news on Phys.org
CFDFEAGURU said:
So I have two questions;

1. Are they correct about "never use C++ for windows form applications"?

Yes, I always give the same advice.

2. Does anyone have a simple example of how to link the two languages together?

Thanks
Matt

Compile the C++ into a dynamic library (dll), then you can import the function. Heres an example

http://www.csharphelp.com/archives/archive52.html
 
Last edited by a moderator: