如何在C#中使用C ++ dll中的函数的指针参数? [英] How to use a pointer parameter of a function from C++ dll in C#?
本文介绍了如何在C#中使用C ++ dll中的函数的指针参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含函数的C ++ dll项目(Win32 dll):
I have C++ dll project (Win32 dll) which contains a function:
int _stdcall abc(int* a)
{
for (int i=0; i<5; i++)
a[i]=i;
return 0;
}
我将其编译为一个名为"xy.dll"的dll文件(已导出abc()).
我想将"xy.dll"与C#中的abc()函数一起使用,如何在C#中使用此函数?谢谢.
I compile it to a dll file (the abc() is exported) called "xy.dll".
I want to use "xy.dll" with abc() function in C#, how to use this function in C#? Thanks.
推荐答案
public int abc (int[] a)
{
for (int i = 0; i < 5; i++)
a[i] = i;
return 0;
}
哦,我找到了解决方案: ^ ]
Oh, I found my solution: http://msdn.microsoft.com/en-us/library/aa446538.aspx#netcfmarshallingtypes_topic5[^]
这篇关于如何在C#中使用C ++ dll中的函数的指针参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文