当前位置:   article > 正文

多字节与宽字符串转换_hidd_getmanufacturerstring 双字

hidd_getmanufacturerstring 双字

//W2M

WCHAR szManufacturer[MAX_PATH+1]={0}; 

HidD_GetManufacturerString(m_DeviceHandle, szManufacturer, MAX_PATH);

char _devicename[100];


int lengthOfMbs = WideCharToMultiByte( CP_ACP, 0, szManufacturer, -1, NULL, 0, NULL, NULL);
char* mbs = new char[ lengthOfMbs ];
WideCharToMultiByte( CP_ACP, 0, szManufacturer, -1, mbs, lengthOfMbs, NULL, NULL);   
memcpy(_devicename,mbs,lengthOfMbs);
delete mbs;
mbs = NULL;
lengthOfMbs = WideCharToMultiByte( CP_ACP, 0, szProduct, -1, NULL, 0, NULL, NULL);
mbs = new char[ lengthOfMbs ];
WideCharToMultiByte( CP_ACP, 0, szProduct, -1, mbs, lengthOfMbs, NULL, NULL); 
strcat(_devicename, " ");
strncat(_devicename,mbs,lengthOfMbs);
delete mbs;

mbs = NULL;

//M2W

char* mstr = "mutil char test";
int lengthOfM = MultiByteToWideChar( CP_ACP, 0,mstr , -1, NULL, 0 );
wchar_t* wcs = new wchar_t[lengthOfM ];
MultiByteToWideChar( CP_ACP, 0,mstr , -1, wcs,lengthOfM );
delete wcs;
wcs = NULL;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/488575
推荐阅读
相关标签
  

闽ICP备14008679号