12/08/2016

convert char* to LPWSTR

refer to below example


char text[] = "something";
wchar_t wtext[20];
mbstowcs(wtext, text, strlen(text)+1);//Plus null
LPWSTR ptr = wtext;

12/07/2016

convert tchar * to char * / char * to tchar*

tchar* -> char*

"Tch" is tchar*
"pStrTch" is char*


TCHAR Tch[MAX_PATH + 1];
int lenOftch = (wcslen(Tch) + 1) * 2;
char * pStrTch = (char*)malloc(sizeof(char)*MAX_PATH);

//tchar* to char*
WideCharToMultiByte(CP_UTF8, 0, Tch, -1, pStrTch, lenOftch, NULL, NULL);
//


char* -> tchar*


char charBuff[]="test";
TCHAR szUniCode[256]={0,};
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, charBuff, strlen(charBuff), szUniCode, 256);