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

  • Thread starter Thread starter CFDFEAGURU
  • Start date Start date
  • Tags Tags
    C++ Functions
Click For Summary
C++ is generally not recommended for Windows Forms applications due to the increased complexity and time required for development. Instead, using C# for Windows Forms while linking necessary C++ functions is advised. To connect C++ and C#, one can compile the C++ code into a dynamic link library (DLL), which allows the C# application to import and use the C++ functions. Resources and examples for this linking process are available online, providing guidance for developers transitioning from console applications to Windows Forms.
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
 
Technology 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:
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 15 ·
Replies
15
Views
8K
  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 133 ·
5
Replies
133
Views
10K
  • · Replies 14 ·
Replies
14
Views
7K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
12K
  • · Replies 23 ·
Replies
23
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K