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.结果:

posted @ 2014-11-17 13:29  lwn6  阅读(241)  评论(0编辑  收藏  举报
什么是幸福?天天在做自己想做的事情,家人、同事、朋友、客户、网友都和和睦睦,身体健康、钱包鼓鼓、女朋友天天开心、生活无忧无虑就是最大的幸福