据我了解,Windows #defines TCHAR作为基于构建的应用程序的正确字符类型 - 因此它wchar_t在UNICODE构建中,char否则.
因此,我想知道是否std::basic_string<TCHAR>会更好std::wstring,因为第一个理论上会匹配应用程序的字符类型,而第二个总是宽.
所以我的问题基本上是:在Windows上会std::basic_string<TCHAR>更好std::wstring吗?并且,使用时会有任何警告(即意外行为或副作用)std::basic_string<TCHAR>吗?或者,我应该只std::wstring在Windows上使用而忘记它吗?
我正在尝试FindWindow()从 WinAPI使用,我想从用户那里询问窗口标题的输入:
char *input;
cout << "Window title: ";
cin >> input;
Run Code Online (Sandbox Code Playgroud)
很标准。那么,我如何将其转换为LPCWSTRfor FindWindow()?
我已经尝试了以下方法:_T(input), TEXT(input),(LPCWSTR)input但它们都不起作用。我也尝试使用wchar_t而不是char,但我char在其他地方都需要,所以我会因为使用wchar_t而不是char......