LPCWSTR或LPWSTR与string相互转换
一、目的:
1、在MFC读取ini配置文件中GetPrivateProfileString获取的是LPWSTR,所以需要将其转换为string
二、操作:
1、MFC读取.ini文件字符串的方法
https://blog.csdn.net/qq_40544338/article/details/105991980
①总结:good:亲测
1、参考:LPCWSTR与string相互转换
https://blog.csdn.net/g9208/article/details/102633006
①、string char*转LPCWSTR
LPCWSTR stringToLPCWSTR(std::string orig)
{size_t origsize = orig.length() + 1;const size_t newsize = 100;size_t convertedChars = 0;wchar_t *wcstring = (wchar_t *)malloc(sizeof(wchar_t)*(orig.length() - 1));mbstowcs_s(&convertedChars, wcstring, origsize, orig.c_str(), _TRUNCATE);return wcstring;
}
①、LPCWSTR或LPWSTR转string
string WCharToMByte(LPCWSTR lpcwszStr)
{string str;DWORD dwMinSize = 0;LPSTR lpszStr = NULL;dwMinSize = WideCharToMultiByte(CP_OEMCP, NULL, lpcwszStr, -1, NULL, 0, NULL, FALSE);if (0 == dwMinSize){return FALSE;}lpszStr = new char[dwMinSize];WideCharToMultiByte(CP_OEMCP, NULL, lpcwszStr, -1, lpszStr, dwMinSize, NULL, FALSE);str = lpszStr;delete[] lpszStr;return str;
}
LPCWSTR或LPWSTR与string相互转换相关推荐
- golang []byte 和 string相互转换
原文链接:golang []byte和string相互转换 测试例子 package mainimport ("fmt" )func main() {str2 := "h ...
- Python bytes 和 string 相互转换 - Python零基础入门教程
目录 一.Python bytes 和 string 区别 二.Python string 转 bytes 三. Python bytes 转 string 四.猜你喜欢 基础 Python 学习路线 ...
- char 类型与lpcwstr_CString与LPCWSTR、LPWSTR等数据类型的转换 | 学步园
CString与LPCWSTR.LPWSTR等数据类型的转化 之前我遇到过类似的问题,在以前两篇博文中也提到过类似编码问题: 1. CString与LPCWSTR的转换 LPCWSTR 是Unicod ...
- Python Bytes和String相互转换,解决Bytes转换String时b‘xxx‘问题
Python Bytes和String相互转换 发现Python的在bytes数据转string的时候直接用str(xx)会多一个b'xxx'.然后就很麻烦,后来查了下发现bytes和String相互 ...
- LPCWSTR与string相互转换
来源互联网,侵删 email:infsine@126.com string char*转LPCWSTR LPCWSTR stringToLPCWSTR(std::string orig) {size_ ...
- golang []byte和string相互转换
测试例子: package mainimport ("fmt" )func main() {str2 := "hello"data2 := []byte(str ...
- Qstring 和 String相互转换
1.QString转换String string s = qstr.toStdString(); 2.String转换QString QString qstr2 = QString::fromStdS ...
- wstring与string相互转换
#include <string> #include <locale.h> // 需包含locale.string头文件.使用setlocale函数. std::wstring ...
- [转载]c#中 uint--byte[]--char[]--string相互转换汇总
在在做一些互操作的时候往往需要一些类型的相互转换,比如用c#访问win32api的时候往往需要向api中传入DWORD参数即:uint参数这些数值所表示的数据在实际的应用中可能需要以字符的形式显示,但 ...
最新文章
- python实现实例_用python语言实现斗地主基础版-案例
- (转)Android 判断用户2G/3G/4G移动数据网络
- OpenCASCADE:读IGES
- There is no row in position 0
- 谷歌看下!罗永浩谈谷歌砍掉平板线 :主要是因为软件太烂
- [转]B树(多向平衡查找树)详解
- spark sql建表的异常
- 硬核!如何全面系统地自学 Java ?
- SC0095-AT32F437使用USB挂载SD卡作为U盘使用
- ASP站内搜索代码#
- Window系统64位下的x86文件夹
- Cisco CCIE之建立详细的故障检测检查表
- Flutter开发日常练习-小猫咪杂货店(新增欢迎页,广告页和侧滑页面)
- 宝元系统通讯软件recon_优软科技会场式电话录音系统
- 什么是网站权重以及提升权重的方法
- 编写名为censor的函数,用来把字符串中出现的每一处字母“foo”替换成“xxx”。例如,字符串“food fool”会变为“xxxd xxxl”。再不失清晰性的前提下程序越短越好
- Squeeze-and-Attention Networks for Semantic Segmentation解读
- numpy提取某行(列)或某几行(列)
- mysql数据库学习之sql调优思路
- 以太坊源码分析(53)以太坊测试网络Clique_PoA介绍