开发者

Calling Unmanaged C++ code from C#

开发者 https://www.devze.com 2023-02-10 14:15 出处:网络
I have zero experience in C++, but have a few years C# experience. Are there an examples out there showing how I can create a method in a C++ program whic开发者_如何学Goh is then called from a C# pro

I have zero experience in C++, but have a few years C# experience.

Are there an examples out there showing how I can create a method in a C++ program whic开发者_如何学Goh is then called from a C# program using the DLL?

Cheers


Using p/invoke, you can call C++ code from C#.

Read this: Calling Win32 DLLs in C# with P/Invoke

Another small yet good article : Using P/Invoke to Access Win32 APIs

--

EDIT:

This aritcle explains how to create a DLL library in C and then use it with C#


You can also try compiling the C++ code in Visual Studio to VC++, which is plain old .NET. Avoid the p/invoke, if the code is compatible.


Create some function in C++ with "extern "C"" to avoid the c++ name mangling and then use PInvoke as suggested by Nawaz is the better way.

0

精彩评论

暂无评论...
验证码 换一张
取 消