LPCWSTR是什么类型呢? 
看看如何定义的:

typedef const wchar_t* LPCWSTR;

顾名思义就是: 
LPCWSTR是一个指向unicode编码字符串的32位指针,所指向字符串是wchar型,而不是char型。

转换函数  直接可以使用

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;
}

不存在从std::string转换为const char*的适当函数

string a;

a.c_str();//即可实现从从std::string转换为const char*

C++不存在从std::string转换为LPCWSTR的适当函数的更多相关文章

  1. C++ 将 std::string 转换为 char*

    参考: std::string to char* C++ 将 std::string 转换为 char* 目前没有直接进行转换的方法.必须通过string对象的c_str()方法,获取C-style的 ...

  2. [C/C++标准库]_[0基础]_[怎样实现std::string自己的Format(sprintf)函数]

    场景: 1.  C语言有自己的sprintf函数,可是这个函数有个缺点,就是不知道须要创建多大的buffer, 这时候能够使用snprintf函数来计算大小,仅仅要參数 buffer为NULL, co ...

  3. VC++ 中使用 std::string 转换字符串编码

    目录 第1章说明    1 1.1 代码    1 1.2 使用    4 第1章说明 VC++中宽窄字符串的相互转换比较麻烦,借助std::string能大大减少代码量. 1.1 代码 函数声明如下 ...

  4. TCHAR和CHAR类型的互转,string 转lpcwstr

    https://www.cnblogs.com/yuguangyuan/p/5955959.html 没有定义UNICODE,所以它里面的字符串就是简单用" "就行了,创建工程的时 ...

  5. QString, Std::string, char *相互转换

    Qt 库中对字符串类型进行了封装,QString 类提供了所有字符串操作方法,给开发带来了便利. 由于第三方库的类型基本上都是标准的类型,即使用std::string或char *来表示字符 (串) ...

  6. c++ istream转换为std::string

    std::istreambuf_iterator<char> eos; std::string s(std::istreambuf_iterator<char>(stream) ...

  7. std::string find 的返回值

    std::string  的方法 find,返回值类型是std::string::size_type, 对应的是查找对象在字符串中的位置(从0开始), 如果未查找到,该返回值是一个很大的数据(4294 ...

  8. UTF8与std:string互转

    Ajax请求发送的UTF8编码字符串传到后台使用std:string进一步处理,如果包含中文会出现中文乱码的问题: 特找了一下转码的解决方法,直接代码如下:  C++ Code  1234567891 ...

  9. C++手稿:std::string

    字符串在非常多编程语言中已经成为基本数据类型,C语言中我们使用char*来手动申请和维护字符串, 在C++中,能够使用std::string来方便地创建和操作字符串. string是一个模板类.它有b ...

随机推荐

  1. SPM——How to use github

    In this semester, we take a class called 'Software Project Management'. And in this class, we have l ...

  2. [Python] map Method

    Map applies a function to all the items in an input_list Blueprint map(function, list_of_inputs) Mos ...

  3. 利用 Babel 玩转你的代码

    我在团队帮助开发 Node 工具时,遇到了需要对多份相似的代码进行一定的处理,但又不能改变原本仓库的代码,这个非常像我们的编译工具做的事情.在一开始的时候,参考了类似 FIS 的功能,简单参照使用代码 ...

  4. VUE项目 - IE报vuex requires a Promise polyfill in this browser问题解决

    第一步: 安装 babel-polyfill . babel-polyfill可以模拟ES6使用的环境,可以使用ES6的所有新方法 npm install --save babel-polyfill ...

  5. JSP中内置对象pageContent的使用

    public class TestPageContext { public void getSomething(PageContext page){ ServletRequest request = ...

  6. Application.streamingAssetsPath

    [Application.streamingAssetsPath] This API contains the path to the StreamingAssets folder (Read Onl ...

  7. SimpleReflection

    [SimpleReflection] 取法线的x.y作为reflection-map的uv. Shader "Custom/SimpleReflection" { Properti ...

  8. Docker构建redis cluster集群

    准备工作 安装gcc ruby 解压编译redis Redis 是 c 语言开发的.安装 redis 需要 c 语言的编译环境.如果没有 gcc 需要在线安装. yum install gcc-c++ ...

  9. Linux gperf命令

    一.简介 GNU 的 gperf 工具是一种 "完美的" 散列函数,可以为用户提供的一组特定字符串生成散列表.散列函数和查找函数的 C/C++ 代码.通过本文学习如何使用 gper ...

  10. IP多播技术及其应用

    随着全球互联网(Internet)的迅猛发展,上网人数正以几何级数快速增长,以因特网技术为主导的数据通信在通信业务总量中的比列迅速上升,因特网业务已成为多媒体通信业中发展最为迅速.竞争最为激烈的领域. ...