First of all create a C++ library project, and add
tools.cpp:
extern "C" __declspec(dllexport) int test()
{
return 42;
}
Call from C# like this:
using System;
using System.Runtime.InteropServices;
namespace ToolsTest
{
public class Tools
{
[DllImport("tools.dll")]
public static extern int test();
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Tools.test());
}
}
}
No comments:
Post a Comment