附加信息我正在构建一个使用WinHttpOpenRequest Api的应用程序,它需要LPCWSTR作为对象名称并使用visual studio 2008
Fer*_*cio 12
最简单的方法是使用ATL:
#include <Windows.h>
#include <atlbase.h>
#include <iostream>
int main(int argc, char *argv[]) {
USES_CONVERSION;
LPCSTR a = "hello";
LPCWSTR w = A2W(a);
std::wcout << w << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当函数退出时,将释放由A2W(ANSI到Wide)分配的任何内存.