How to convert std::wstring to a TCHAR*
std::wstring.c_str() returns a wchar_t*. How do I get from wchar_t* to TCHAR*, or from std::wstring to TCHAR* Thanks #include <atlconv.h> TCHAR *dst = W2T(src.c_str()); Will do the right thing in ANSI or Unicode builds. use this : wstring str1(L"Hello world"); TCHAR * v1 = (wchar_t *)str1.c_str(); TCHAR* is defined to be wchar_t* if UNICODE is defined, otherwise it's char*. So your code might look something like this: wchar_t* src; TCHAR* result; #ifdef UNICODE result = src; #else //I think W2A is defined in atlbase.h, and it returns a stack-allocated var. //If that's not OK, look at the