There is such a definition:

#ifdef UNICODE typedef std::wstring tstring #else typedef std::wstring tstring #end if 

Then I have this code:

 tstring str = TEXT("cd My_Folder"); LPCTSTR lpStr = str.c_str(); #ifdef UNICODE _wsystem(lpStr); #else system(lpStr); #endif 

However, the program crashes. There is a suspicion that I am doing the wrong row conversion Tell me how to.

  • With or without UNICODE falls? LPCTSTR relies on _UNICODE (with an underscore). - αλεχολυτ
  • @alexolut, crashes with UNICODE. And if you change to _UNICODE, it is not going at all. - neo

1 answer 1

You got it wrong. It is necessary so:

 #ifdef UNICODE typedef std::wstring tstring #else typedef std::string tstring #end if 

You have std::wstring instead of std::string both times.


And you either must have both the UNICODE and _UNICODE , or none of them. Otherwise, wait for problems.