2. File->New Project ->Other Languages -> C# -> Windows Application
3. Create your GUI using the toolbox and double click the form to view its code.
4. Add using System.Runtime.InteropServices; in the header
5. Import your DLL using
[DllImport("DLL Name")] in the C# class
above it constructor definition.
3. Declare the exported function(s) of the DLL with keywords public static extern
4. Call the exported function anywhere in the program in the usual manner.
Example:
using System;
using System.Runtime.InteropServices;
public partial class Form1 : Form
{
[DllImport("cppfile.dll")] // the whole path has to be inserted within the quotes
public static extern int abc(); // this should be the function we exported when we created //the DLL
}
call the function abc() anywhere in the usual way you handle a function call.
5. click F5 to run the application.
No comments:
Post a Comment