C#调用的dll中函数返回值问题
先上代码
头文件
//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进行操作呢