dll导入
1、纯函数导入
定义CPP:
BOOL EXPORT FUN(LPCTSTR lpszSrc, LPCTSTR lpszDst)
导入CPP:
声明:BOOL __declspec(dllimport) FUN(LPCTSTR lpszSrc, LPCTSTR lpszDst);
二、C#导入C++的DLL
namespace ConsoleApplication1 { class CppDll { [DllImport("MyDLLFun.dll", EntryPoint = "Add", CallingConvention = CallingConvention.Cdecl)] public static extern int Add(int x, int y); } class Program { static void Main(string[] args) { int a = CppDll.Add(1, 2); Console.WriteLine(a); } } }