C#调用C++的Dll如何传递CList

.Net技术 码拜 9年前 (2015-07-10) 1662次浏览 0个评论
 

C#调用C++的Dll如何传递CList

C++中声明
C_DLL_EXPORT bool TSL_Com_Run(CList<CPoint, CPoint &> ltpt);
C#中如何导入该函数?

 
//调用
[DllImport(“你的dll名字.dll”, EntryPoint = “TSL_Com_Run”)]
private static extern bool TSL_Com_Run();
 
1、首先把你的dll复制到debug的文件夹中,2、//声明你的dll并使用方法
[DllImport(“你的dll名字.dll”, EntryPoint = “TSL_Com_Run”)]
private static extern bool TSL_Com_Run(CList<CPoint, CPoint &> ltpt);
3、使用dll
bool a= TSL_Com_Run();

100分

参数类型可见 http://social.msdn.microsoft.com/Forums/zh-CN/visualcshartzhchs/thread/83a63903-0f47-4797-8217-9912b5665ff1/
 
谢谢你的回复!
我的问题与
http://social.msdn.microsoft.com/Forums/zh-CN/visualcshartzhchs/thread/83a63903-0f47-4797-8217-9912b5665ff1/
相同。

我用如下结构传递变长数组
struct MyResultList
{
int iCount;
CPoint pt[];
};
结果可以传出来,但由于未提前为数组分配内存,将其他数据的内存给搞乱了。
我应该如何传递?

 
问题未解决!
C++的Dll如何向C#中传递动态数组?谁用过指点下啊。
 
看看这的教程吧:
http://www.itnose.net/detail/745164.html

___________
free c#.net qr creator
c#.net barcode generator


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明C#调用C++的Dll如何传递CList
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!