C#中调用VC++的DLL

C# 2022-02-27 17:00:23

C#中调用VC++的DLL本实例在开发中有用的可以参考。
[DllImport("diaCallBackDll.dll")]
public static extern void show();

[DllImport("diaCallBackDll.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int add_CallBack_test(int a, int b, cb_func f);

public static void cb_funcc(int re)
{
Console.WriteLine("result=[{0}]", re);

return;
}

static void Main(string[] args)
{
//show();

int i = add_CallBack_test(7, 2, cb_funcc);

Console.Read();
}