这个网上很多。但是没有能运行起来的。自己经过一周多的摸索进行稍微总结下。首先是

C++下的声明:

头文件:extern "C" _declspec(dllexport)int Add(int sm);
Cpp文件:
int Add(int sm)
{
	int insx=20;
	sm=insx+sm;
	return sm;
}

生成dll把所生成的拷到C#的bin/debug下

在C#下调用:

[DllImport("mediastream.dll", EntryPoint = "Add", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
        public static extern int Add(int sm);

好了就可以调用了Add了。

虽然过程很简单但是摸索了好久才弄出来的。

相关文章:

  • 2021-12-26
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2022-01-16
  • 2021-12-23
  • 2022-02-05
猜你喜欢
  • 2021-05-31
  • 2022-12-23
  • 2022-01-11
  • 2022-01-21
  • 2021-05-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案