??????????????????C++????????о??′?C# ?е???DLL
?????????????????????????????DllImport??????
????????DllImport???????????
????using System.Runtime.InteropServices;
????public class XXXX{
????[DllImport(“MyDLL.dll")]
????public static extern int mySum (int a??int b);
????}
????[DllImport(“MyDLL.dll")]
????public static extern int mySum (int a??int b);
??????????DllImport??????????????????????????????????????????????????????
?????????????
?????????е???? ???   mySum(a??b);??????
?????????????е???: XXXX. mySum(a??b);
????[DllImport(“MyDLL.dll”)]????????????????????????? [DllImport(“MyDLL.dll"?? EntryPoint=" mySum "??CharSet=CharSet.Auto??CallingConvention=CallingConvention.StdCall)] EntryPoint: ????????? DLL ??????????????????й?????????? ??
????CharSet: ????????????????? String ???????? (?????UNICODE)
????CallingConvention?????????????????(???WINAPI)(??α??潲?????
????SetLastError ???????÷????????????????????????? SetLastError Win32 API ???? (C#?????false )
????int ????
[DllImport(“MyDLL.dll")]
//?????int ????
public static extern int mySum (int a1??int b1);
//DLL??????
extern “C” __declspec(dllexport)  int WINAPI mySum(int a2??int b2)
{
//a2 b2??????a1 b1
//a2=..
//b2=...
return a+b;
}
//????????int ????
public static extern int mySum (ref int a1??ref int b1);
//DLL??????
extern “C” __declspec(dllexport)  int WINAPI mySum(int *a2??int *b2)
{
//?????? a1?? b1
*a2=...
*b2=...
return a+b;
}
????DLL ?貧??char *????
[DllImport(“MyDLL.dll")]
//?????
public static extern int mySum (string  astr1??string bstr1);
//DLL??????
extern “C” __declspec(dllexport)  int WINAPI mySum(char * astr2??char * bstr2)
{
//???astr2 bstr 2  ??astr1 bstr1???????
return a+b;
}