Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C# with C++ functions

  1. Aug 24, 2009 #1
    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
     
  2. jcsd
  3. Aug 24, 2009 #2

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    Last edited by a moderator: May 4, 2017
  4. Aug 24, 2009 #3
    Yes, I always give the same advice.

    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: Apr 24, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: C# with C++ functions
  1. C++ function (Replies: 3)

  2. Functions in c (Replies: 1)

  3. Fread() C function (Replies: 2)

  4. Random function in C (Replies: 31)

Loading...