首先在C#工程下面安装第三方插件包    

  安装方法:Tools --> Library Package Manager --> Package Manager Console

  Install-Package UnmanagedExports

并添加:

using System.Runtime.InteropServices;
using RGiesecke.DllExport;

class Test
{
  [DllExport("add", CallingConvention = CallingConvention.Cdecl)]
  public static int TestExport(int left, int right)
  {
     return left + right;
  } 
}

注意点击Project-->properties-->Application-->Output type-->Class Library

点击工程Build即可生成dll

调用的时候用普通的C++调用dll的方式即可

 __declspec(dllimport) void getx(int a, int b);

 

相关文章:

  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
  • 2021-12-03
  • 2021-09-24
  • 2021-06-15
  • 2021-07-26
  • 2021-08-05
猜你喜欢
  • 2022-12-23
  • 2021-08-31
  • 2022-12-23
  • 2021-07-07
  • 2021-10-20
  • 2022-12-23
  • 2022-02-06
相关资源
相似解决方案