码迷,mamicode.com
首页 > 其他好文 > 详细

Unicode 转码 Ansi ,用于读取注册表后的值转换

时间:2016-01-28 20:45:46      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

 1 char* UnicodeToAnsi(TCHAR* wstr)     //转换字符编码
 2 {
 3     if( !wstr )
 4         return NULL;
 5 
 6     int strlen = ::WideCharToMultiByte(CP_ACP, NULL, wstr, wcslen(wstr), NULL, 0, NULL, FALSE);
 7     char* str = new char[strlen + 1];
 8     ::WideCharToMultiByte(CP_ACP, NULL, wstr, wcslen(wstr), str, strlen, NULL, FALSE);
 9     str[strlen] = \0;
10 
11     return str;
12 }

读取注册表后转换为可用的 字符串!!!

Unicode 转码 Ansi ,用于读取注册表后的值转换

标签:

原文地址:http://www.cnblogs.com/Black-Crow/p/5167197.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!