首页
社区
课程
招聘
[求助]VC6中ListCtrl控件SetItemText函数参数问题
发表于: 2012-5-5 16:50 21540

[求助]VC6中ListCtrl控件SetItemText函数参数问题

2012-5-5 16:50
21540
本人对VC不熟,学者做了一个抓包工具,可是编译总不对
申请变量
#define DEF_BUF_SIZE 2048
in_addr addr ;
WCHAR szTempBufW[DEF_BUF_SIZE] = {0} ;
通过抓包实现信息插入ListCtrl控件中,代码如下
addr.S_un.S_addr = lpPackInfo->nSourIp ;
MultiByteToWideChar (CP_ACP, 0, inet_ntoa(addr), -1, szTempBufW, sizeof(szTempBufW) );
this->m_PackList.SetItemText ( nCount, 3, szTempBufW) ;//问题出现在这里
可是编译通不过error C2664: 'SetItemText' : cannot convert parameter 3 from 'unsigned short [2048]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
我明明申请的szTempBufW看了是unsigned short 类型,函数SetItemText第3个参数类型说明也是unsigned short 类型,编译时为什么要为char*型才行?而且如果我修改强制转换类型话也不对(我要用来显示IP地址的,修改后就只有个位数了),事例上用的是VS2005可通过,用VC6怎么改?

PS:其他都对,94这个参数类型不对,伤脑筋!哪位大侠帮帮忙了!

[课程]Linux pwn 探索篇!

收藏
免费 0
支持
分享
最新回复 (5)
雪    币: 270
活跃值: (97)
能力值: ( LV8,RANK:140 )
在线值:
发帖
回帖
粉丝
2
VC6默认是非UNICODE工程。你应该用TCHAR
2012-5-5 17:29
0
雪    币: 2033
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
都试过TCHAR回复
error C2664: 'MultiByteToWideChar' : cannot convert parameter 5 from 'char [2048]' to 'unsigned short *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
2012-5-5 17:44
0
雪    币: 90
活跃值: (91)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
楼主为什么要把数据转为UNICODE类型?
SetItemText接受的是非宽字符类型的
2012-5-5 19:36
0
雪    币: 2033
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
改CHAR也不行啊error C2664: 'MultiByteToWideChar' : cannot convert parameter 5 from 'char [2048]' to 'unsigned short *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
用UNICODE我想是作者要显示IP地址和兼容性考虑吧
2012-5-5 20:35
0
雪    币: 60
活跃值: (28)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
直接用CString算了
2012-5-30 13:18
0
游客
登录 | 注册 方可回帖
返回
//