C#调用的dll中函数返回值问题

dxpfigo dxpfigo 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
先上代码

头文件
//head begin
//dll_01.h
typedef struct point
{
double X;
double Y;
}Point;

Point * CaculateTrack( unsigned int step );
//head end

源文件
//.cpp
//dll_01.cpp
Point * CaculateTrack( unsigned int step )
{
Point * pTrackPoint = NULL;

pTrackPoint = (Point*)calloc( step + 1, sizeof( Point ) );
g_TrackX = (double*)calloc( step, sizeof( double ) );
g_TrackY = (double*)calloc( step, sizeof( double ) );

for( unsigned int i = 1; i <= step; i++ )
{
pTrackPoint[ i ].X = g_TrackX[ i ] = g_TrackX[ i - 1 ] + i;
pTrackPoint[ i ].Y = g_TrackY[ i ] = g_TrackY[ i - 1 ] + i + 1;

}
return pTrackPoint;
}
//end .cpp

//C#中的声明部分
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct point
{

/// double
public double X;

/// double
public double Y;
}
[System.Runtime.InteropServices.DllImportAttribute("Dll_01.dll", EntryPoint = "iNEMO_CaculateTrack")]
public static extern System.IntPtr CaculateTrack( uint step) ;
//end C#

就这样,返回值变为了intptr类型,请问大家我想要取出调用函数中的返回值怎么样对intptr进行操作呢
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
dxpfigo
进程/线程/DLL 15,466 成员 49,169 内容