(for example "MyDll.dll" which we created in this post click here )
- Create a new C#.net windows application.
- Copy the "MyDll.dll" to your project path, which we created in this post Click here.
- Add this this following lines as below.
using System.Runtime.InteropServices; //add this line
namespace WindowsApplication1
{
public partial class Form1 : Form
{
[DllImport("MyDll.dll", CharSet=CharSet.Auto)] //add this line
internal static extern Int32 egAdd(int a, int b); //add this line
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int nRes = egAdd(2, 4); //add this line
MessageBox.Show(nRes.ToString()); //add this line
}
}
}
No comments:
Post a Comment