Unicode환경에서 CString을 LPWSTR로 형변환 하는 방법입니다.

LPWSTR ConvertToUnicode(CString cString)
{
	int nBufSize = cString.GetLength() + 1;
	LPWSTR lpws = new wchar_t[nBufSize];

	if (lpws != NULL)
	{
		#if defined(_UNICODE)
		lstrcpy(lpws, cString); // If Unicode is defined, just copy the string.
		#else
		// mbstowcs() would work here as well...
		MultiByteToWideChar(CP_ACP, 0, cString, nBufSize, lpws, nBufSize * 2);
		#endif // _UNICODE
	}
	return lpws; // Caller must delete!
}
lynn.baek's profile image

lynn.baek

2018-07-09 14:37

Read more posts by this author