急!c#调用c++写的dll,如何传递一维数组作为参数
C++dll函数如下
power(int handle,usigned char meas,unsigned long freq,unsigned short band,unsigned short sample,unsigned long num,unsigned char trigger, unsigned char type,short threshold,short start_time,short *power,unsigned long *act_freq)
这个函数里面power和actfreq是输出,power指向了一个数组,num是其大小,不知道怎么能把这个*power数组的值传到C#里。
我转换成了
[DllImportAttribute("tc_rfid.DLL")]
public static extern int power_time(int handle, Byte meas, UInt32 freq, UInt16 band, UInt16 sample, UInt32 num, Byte trigger, Byte type, System.Int16 threshold, System.Int16 start_time,ref short power,ref uint act_frequency);
调用时声明short[] power=new short[num];
power(....,ref power[0],ref act_frequency)
调用时会提示我尝试读写保护内存,求教达人!