C++ unsigned long* 装换为C#是什么?加急

zhibingfeng 2010-03-05 09:16:26
int rf_card(int icdev,unsigned char _Mode,unsigned long *_Snr);
c#中
[DllImport("mwrf32")]
public static extern int rf_card(int icdev, byte _Mode, long[] _Snr);
这样好像不行 有转过的请指教下
还有unsigned char *
...全文
1398 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
soaringbird 2010-03-09
  • 打赏
  • 举报
回复
其实byte[]是万能的,只要空间足够即可
phl1025 2010-03-09
  • 打赏
  • 举报
回复
好像是long[],不过好像都可以int[]
soaringbird 2010-03-09
  • 打赏
  • 举报
回复
如果unsigned long *_Snr是一个整数数组,可以用int[],
如果仅仅是一个整数的指针,就用ref int
RFEZGC 2010-03-09
  • 打赏
  • 举报
回复
int rf_card(int icdev,unsigned char _Mode,unsigned long *_Snr);


public static extern int rf_card(int icdev, byte _Mode, long[] _Snr);

看来你对指针都不懂的
如果是unsigned char* 那么 _Mode 应该是string, 如果是unsigned char 设置为byte也对

unsigned long *是个指针类型, 在c#用[]是不对的,改ref或out unsigned long 在c++是32位的,也就是跟c#的uint的取值范围一样,而c#的long是64位的,你用long就是不对的。
你应该把long改int 或short,或者是uint 或ushort 那样取值范围大一点,但不允许负数
zhibingfeng 2010-03-08
  • 打赏
  • 举报
回复
引用 8 楼 xingyuebuyu 的回复:
引用 6 楼 zhibingfeng 的回复:引用 5 楼 xingyuebuyu 的回复:public static extern int rf_card(int icdev,  byte _Mode, uint ref _Snr); C++中unsigned long是32位数据你的意思是public static extern int rf_card(int icdev,  byte _Mode, ref uint _Snr);这样吧 还是不行 晕了 返回还是执行失败 测试DEMO能通过的。。。

执行失败是指有报错还是返回值不对?
另外测试DEMO能通过的代码贴出来看看

返回值不对 返回值是1 0才是成功 测试DEMO是个程序 没代码 囧
http://topic.csdn.net/u/20100308/10/f339d3fa-c4ec-4b70-8c82-a346e5f1a9ea.html?seed=1924537743&r=63774007#r_63774007
我又开了个贴 那写得比较详细 你要是看到这个回复 请去那边看看吧 谢谢xingyuebuyu啦
xingyuebuyu 2010-03-08
  • 打赏
  • 举报
回复
引用 6 楼 zhibingfeng 的回复:
引用 5 楼 xingyuebuyu 的回复:public static extern int rf_card(int icdev,  byte _Mode, uint ref _Snr); C++中unsigned long是32位数据
你的意思是public static extern int rf_card(int icdev,  byte _Mode, ref uint _Snr);这样吧 还是不行 晕了 返回还是执行失败 测试DEMO能通过的。。。


执行失败是指有报错还是返回值不对?
另外测试DEMO能通过的代码贴出来看看
zhibingfeng 2010-03-08
  • 打赏
  • 举报
回复
木有人来了 。。愁死淫啊~
zhibingfeng 2010-03-08
  • 打赏
  • 举报
回复
引用 5 楼 xingyuebuyu 的回复:
public static extern int rf_card(int icdev,  byte _Mode, uint ref _Snr);

C++中unsigned long是32位数据

你的意思是public static extern int rf_card(int icdev, byte _Mode, ref uint _Snr);这样吧 还是不行 晕了 返回还是执行失败 测试DEMO能通过的。。。

kun2009 2010-03-08
  • 打赏
  • 举报
回复
[MarshalAs(UnmanagedType.LPArray)]byte[] p_string
cjcgy 2010-03-08
  • 打赏
  • 举报
回复
unsigned char * 对应string或者StringBuilder
烈火蜓蜻 2010-03-08
  • 打赏
  • 举报
回复
ulong

回复内容太短了!
Justin-Liu 2010-03-08
  • 打赏
  • 举报
回复
引用 7 楼 zhibingfeng 的回复:
木有人来了 。。愁死淫啊~

.......................
cjcgy 2010-03-08
  • 打赏
  • 举报
回复
好像相当于void*, 算IntPtr
xingyuebuyu 2010-03-05
  • 打赏
  • 举报
回复
public static extern int rf_card(int icdev, byte _Mode, uint ref _Snr);

C++中unsigned long是32位数据
xray2005 2010-03-05
  • 打赏
  • 举报
回复
public static extern int rf_card(int icdev, byte _Mode, ulong ref _Snr);
zhibingfeng 2010-03-05
  • 打赏
  • 举报
回复
int rf_card(int icdev,unsigned char _Mode,unsigned long *_Snr);
那这个函数就变成 int rf_card(int icdev, byte _Mode, ulong[] _Snr); 好像还是不对..也不知道问题出在哪儿
zhibingfeng 2010-03-05
  • 打赏
  • 举报
回复
谢谢楼上 我试试先............
hustcyb 2010-03-05
  • 打赏
  • 举报
回复
C++中unsigned long *对应的C#的类型应该为ulong[]才对吗,还有unsigned char *在C#中对应的类型为对byte[]

110,572

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧