CString str = CString(buffer); USES_CONVERSION; LPWSTR wszClassName = new WCHAR[str.GetLength() + 1]; wcscpy((LPTSTR)wszClassName, T2W((LPTSTR)str.GetBuffer(NULL))); str.ReleaseBuffer();