我用C#调用dll的函数,在函数当中返回二维数组,请问有什么方法呢?
我在网上看了很多方法,很多都不管用,后来看到一个可以在C++中返回二维数组的方法
C++代码如下//Cpp代码
typedef int (*PTR)[4];
TREEDLL_API PTR printDegree()
{
getReTree(root, 0);
reTree[0][1] = allDegree;
int (*x)[4] = reTree;
return x;
}
//接口页面代码
extern "C" TREEDLL_API typedef int (*PTR)[4];//用于传递PTR类型到C#
extern "C" TREEDLL_API PTR printDegree();以上代码可以顺利编译通过。
但在C#中调用这个函数的时候出问题了/*
// 没有这一段时程序说没定义PTR,有这一段时程序说这个声明无效
[DllImport("D:\\inetpub\\MuiscPlatform\\user\\TreeDLL.dll", EntryPoint = "printDegree", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public extern static typedef int (*PTR)[4];
*/
[DllImport("D:\\inetpub\\MuiscPlatform\\user\\TreeDLL.dll", EntryPoint = "printDegree", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public extern static PTR printDegree();
我应该怎么办呢?希望大家可以帮帮我~~~~~
我在网上看了很多方法,很多都不管用,后来看到一个可以在C++中返回二维数组的方法
C++代码如下//Cpp代码
typedef int (*PTR)[4];
TREEDLL_API PTR printDegree()
{
getReTree(root, 0);
reTree[0][1] = allDegree;
int (*x)[4] = reTree;
return x;
}
//接口页面代码
extern "C" TREEDLL_API typedef int (*PTR)[4];//用于传递PTR类型到C#
extern "C" TREEDLL_API PTR printDegree();以上代码可以顺利编译通过。
但在C#中调用这个函数的时候出问题了/*
// 没有这一段时程序说没定义PTR,有这一段时程序说这个声明无效
[DllImport("D:\\inetpub\\MuiscPlatform\\user\\TreeDLL.dll", EntryPoint = "printDegree", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public extern static typedef int (*PTR)[4];
*/
[DllImport("D:\\inetpub\\MuiscPlatform\\user\\TreeDLL.dll", EntryPoint = "printDegree", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public extern static PTR printDegree();
我应该怎么办呢?希望大家可以帮帮我~~~~~
解决方案 »
- asp.net内存流转换成图片
- ASPX页面中 <%= 与 <%#的区别
- 关于GridView中图片选择显示的问题。
- GridView的问题
- 向项目经理求教: 这样的项目要多上时间
- 问个超级菜的问题。立马结!
- vs2003 中的Ajax 能不能像2005中那样,将很多不想刷新的控件放到一个panel中,一块应用ajax?
- 关于repeater控件绑定代码的整合
- 感谢各位网友支持,让我也得到一个小星
- 使用EventLog.CreateEventSource会为何会出现没有权限访问注册表
- ASp.NEt 页面中 如何将一个GBK 类型的字符串 转换成UTF-8 的字符串 急急急
- 如何在本页面实现回复功能
然后using XXX;最后调用方法返回二维数组。