std::string ws2s(const std::wstring& str)
{
char* pElementText;
int iTextLen;
// wide char to multi char
iTextLen = WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, NULL, 0, NULL, NULL);
pElementText = new char[iTextLen + 1];
memset((void*)pElementText, 0, sizeof(char)* (iTextLen + 1));
::WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, pElementText, iTextLen, NULL, NULL);
std::string strText;
strText = pElementText;
delete[] pElementText;
return strText;
}
std::string strKEy = ws2s(pKey);//pKey为WCHAR类型
char pStr[256] = {0};
strcpy_s(pStr, 256, strKEy.c_str());