我有非托管 C# DLL:
[DllExport(ExportName = "GetStudentsList", CallingConvention = CallingConvention.StdCall)]
static public List<StudentsStruct>GetStudentsList() { return List<StudentsStruct>; }
[DllExport(ExportName = "maxElement", CallingConvention = CallingConvention.StdCall)]
static public int maxElement(int a, int b) { return c; }
我想List<StudentsStruct>
从函数中返回。
我想在 C++ 应用程序中运行上面的函数:
using GetStudentsListFn = List<StudentsStruct> (__stdcall *) (void);
GetStudentsListFn GetStudentsList = reinterpret_cast<GetStudentsListFn> (GetProcAddress(mod, "GetStudentsList"));
List<StudentsStruct> myList = GetStudentsList();
using MaxElementFn = int(__stdcall *) (int a, int b);
MaxElementFn maxElement = reinterpret_cast<MaxElementFn> (GetProcAddress(mod, "maxElement"));
std::printf("max: %d\n", maxElement(1, 2));
MaxElement() 函数运行良好,因为它返回一个 int。但我想将“StudentsStruct”的列表/数组从 C# 返回到 C++。