• Advertisement
Sign in to follow this  

Tools Programming C++ Wrapper in C#

This topic is 4042 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am new to these forums and I did a search looking for this topic, and I found similar topics but nothing that addressed what I wanted to accomplish. I am currently working to put together a series of tools. One of which is a Particle System. The Direct3D wrapper that I am using is C++. I want to shove the c++ wrapper into a DLL and use it in a windows forms c# application. My question is that, is this possible? Is this the best way to go about creating my tools? I traditionally have done all of my tools in MFC and C# forms are much easier to put together and produce better results. Thanks a lot!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by WBlacklidge
I want to shove the c++ wrapper into a DLL and use it in a windows forms c# application. My question is that, is this possible?


Yep - what you are looking for is called the pinvoke mechanism - it allows you to call native code from unmanaged code. There are lots and lots of resources out there on it, so just search for it. (Brief Intro)

Quote:
Is this the best way to go about creating my tools? I traditionally have done all of my tools in MFC and C# forms are much easier to put together and produce better results.

I'm sure this is up for debate, but I see it as pretty convienient. Of course, you are always going to have to juggle maintaining the managed->native links vs just converting it to C#. I guess it depends on how complicated your interfaces are and how much of them you have to expose.

Share this post


Link to post
Share on other sites
Thanks a lot! I am going to look into it. I am going to use the tutorials to create my dll and then I have to figure out how to get a real time loop, something like the OnTimer() call in MFC. I hear that I am going to have to look into using the Timer class in C#. I just need to be able to loop as if it were a main game loop or something. I have only started working with C# in the last 2 weeks so I am still pretty unfamiliar with it. Thanks for the advice!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement