C++ Code:
bool LPWSTR2String(std::string& outString, const LPWSTR inLPWSTR, UINT codepage = CP_ACP)
{
bool retCode = false;
char* temp = 0;
int bytesRequired;
bytesRequired = WideCharToMultiByte(codepage, 0, inLPWSTR, -1, 0, 0, 0, 0);
if (bytesRequired > 0)
{
temp = new char[bytesRequired];
int rc = WideCharToMultiByte(codepage, 0, inLPWSTR, -1, temp, bytesRequired, 0, 0);
if (rc != 0)
{
temp[bytesRequired-1] = 0;
outString = temp;
retCode = true;
}
}
delete [] temp;
return retCode;
}
How i can convert a string to LPWCSTR?
ReplyDeletecheck here http://easytechideas.blogspot.com/2014/11/convert-string-to-lpwstr-c.html
Delete