C#调用C++dll

1.添加命名空间  using System.Runtime.InteropServices;

2.dll的添加和函数的声明(注意一定要放在函数(方法)的外面)  

[DllImport("User32.dll")]
public static extern int MessageBox(int h, string m, string c, int type);

3.使用,在函数内添加

MessageBox(0, "我正在调用c++dll", "C#",0x30);    

4.结果:

原文地址:https://www.cnblogs.com/lwngreat/p/4103397.html