C#????C++??dll???
???????????? ???????[ 2016/11/14 10:28:25 ] ????????.NET C++ Dll???
?????????????????ù???
??????????????C#???
????????--??????cpp???
????// the code is write in c
????#ifdef __cplusplus
????extern "C"{
????#endif
????__declspec(dllexport) int __cdecl add(int a?? int b);
????#ifdef __cplusplus
????}
????#endif
????int add(int a?? int b)
????{
????return a + b;
????}
????AdderImpl????????????????????.dll??
???????dll????????
????????AdderWapper.cs?д??????
????using System;
????using System.Collections.Generic;
????using System.Linq;
????using System.Text;
????using System.Threading.Tasks;
????using System.Runtime.InteropServices;
????namespace TestApp
????{
????class AdderWapper
????{
????[DllImport("AdderImpl.dll"?? CallingConvention = CallingConvention.Cdecl)]
????static extern private int add(int a?? int b);
????static public int performAdd(int a?? int b)
????{
????// convert c# data to c data
????// TODO:
????// call the c interface
????int ret = add(a?? b);
????// convert result from c data to c# data
????// TODO:
????// return the result
????return ret;
????}
????}
????}
????Program.cs?д??????
????using System;
????using System.Collections.Generic;
????using System.Linq;
????using System.Text;
????using System.Threading.Tasks;
????namespace TestApp
????{
????class Program
????{
????static void Main(string[] args)
????{
????int a = 3; int b = 5;
????int c = AdderWapper.performAdd(a?? b);
????System.Console.WriteLine(c);
????}
????}
????}
??????????????dll??exe???????????
????end
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11