c# 调用c++ .dll
首先导入命名空间using System.Runtime.InteropServices;
代码
1 string decodeStr = string.Empty;
2 [DllImport("DataDeCode.dll", CharSet = CharSet.Ansi)] // 插入dll文件 dll文件必须放在bin文件夹下
3 public static extern void DataDeCode(GetSingeMobile func, string Input);
4 //回调委托
5 public delegate void GetSingeMobile(string str);
6
7 public void decode_call_back(string str)
8 {
9 if (str.Length > 10)
10 {
11 decodeStr = str;
12 }
13 }
2 [DllImport("DataDeCode.dll", CharSet = CharSet.Ansi)] // 插入dll文件 dll文件必须放在bin文件夹下
3 public static extern void DataDeCode(GetSingeMobile func, string Input);
4 //回调委托
5 public delegate void GetSingeMobile(string str);
6
7 public void decode_call_back(string str)
8 {
9 if (str.Length > 10)
10 {
11 decodeStr = str;
12 }
13 }
// 调用方法
GetSingeMobile func = new GetSingeMobile(decode_call_back);
DataDeCode(func, result);
GetSingeMobile func = new GetSingeMobile(decode_call_back);
DataDeCode(func, result);

浙公网安备 33010602011771号