当前位置: 代码迷 >> ASP.NET >> C#调用c++Dll指针数组,该如何解决
  详细解决方案

C#调用c++Dll指针数组,该如何解决

热度:9918   发布时间:2013-02-25 00:00:00.0
C#调用c++Dll指针数组
c代码
C/C++ code
  int  _stdcallrd6sn_gethisdata_withinsert(u_int32_t pt, int starttime,int endtime,float *value,int type);

怎么写成C#的代码,返回float数组。
我写的如下:
C# code
 [DllImport(dll_name, EntryPoint = "rd6sn_gethisdata_withinsert")]        public static extern int rd6sn_gethisdata_withinsert(UInt32 pt, int starttime, int endtime, ref  float[] value, int type);DateTime dtend = DateTime.Parse("2012-5-7 10:30:00");            DateTime dtBegin = DateTime.Parse("2012-5-7 10:10:00");            DateTime DataTime1970 = DateTime.Parse("1970-1-1");            int begitime = (int)(dtBegin - DataTime1970).TotalMilliseconds;            int begiendtime = (int)(dtend - DataTime1970).TotalMilliseconds;            long[] vlueflqqq = new long[1];            float[] vluefl = new float[1]; DataPeek.DPG.DPGClass.rd6sn_gethisdata_withinsert(8024, begitime, begiendtime, ref vluefl, 3);

运行出现“指针表尝试读取或写入受保护的内存。这通常指示其他内存已损坏”的错误,请问应该怎么写

------解决方案--------------------------------------------------------
public static extern int rd6sn_gethisdata_withinsert(UInt32 pt, uint starttime, uint endtime, ref float[] value, int type); startime 和endtime改成无符号整形
  相关解决方案