首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-06-07 
C#调用c++Dll指针数组c代码C/C++ codeint_stdcallrd6sn_gethisdata_withinsert(u_int32_t pt, int startti

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改成无符号整形

热点排行