/******************************************************************************************
Function:? ? ? ? ConvertLPWSTRToLPSTR
Description:? ? LPWSTR轉(zhuǎn)char*
Input:? ? ? ? ? lpwszStrIn:待轉(zhuǎn)化的LPWSTR類型
Return:? ? ? ? ? 轉(zhuǎn)化后的char*類型
*******************************************************************************************/
char* ConvertLPWSTRToLPSTR(LPWSTR lpwszStrIn)
{
LPSTR pszOut = NULL;
try
{
if (lpwszStrIn != NULL)
{
int nInputStrLen = wcslen(lpwszStrIn);
// Double NULL Termination?
int nOutputStrLen = WideCharToMultiByte(CP_ACP, 0, lpwszStrIn, nInputStrLen, NULL, 0, 0, 0) + 2;
pszOut = new char[nOutputStrLen];
if (pszOut)
{
memset(pszOut, 0x00, nOutputStrLen);
WideCharToMultiByte(CP_ACP, 0, lpwszStrIn, nInputStrLen, pszOut, nOutputStrLen, 0, 0);
}
}
}
catch (std::exception e)
{
}
return pszOut;
}