use*_*898 2 c++ unicode winapi multibyte
我必须说我是win32 c ++编程的新手,所以我遇到的问题是
某些代码在多字节字符集中编译而不是在Unicode字符集中编译.
我的代码怎么能同时支持?
例如,此NOT仅在Unicode中编译多字节,仅在MultiByte中编译注释向量:
//vector<char> str2(FullPathToExe.begin(), FullPathToExe.end());
vector<wchar_t> str2(FullPathToExe.begin(), FullPathToExe.end());
str2.push_back('\0');
if (!CreateProcess(NULL,
&str2[0],
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi))
Run Code Online (Sandbox Code Playgroud)
使用TCHAR作为字符类型(例如std::vector<TCHAR>),这是:
一个
WCHARifUNICODE定义,CHAR否则.此类型在WinNT.h中声明如下:
Run Code Online (Sandbox Code Playgroud)#ifdef UNICODE typedef WCHAR TCHAR; #else typedef char TCHAR; #endif