我想使用WinAPI中的FindWindow()
,并且我希望能够从用户那里获得窗口标题的输入:
char *input;
cout << "Window title: ";
cin >> input;
非常标准。
那么,我如何将其转换为LPCWSTR
以供FindWindow()
使用呢?
我已经尝试了以下方法:_T(input)
、TEXT(input)
、(LPCWSTR)input
,但它们都没有起作用。
我还尝试使用wchar_t
代替char
,但我在其他地方需要使用char
,所以我会因为使用wchar_t
而得到数十个错误...
FindWindowA
。如果你想支持 UTF-16,那么最好不要在 ANSI 字符数组中存储字符串。 - David HeffernanMyString.c_str()
或&MyString[0]
将其作为参数传递给 API 函数。 - ST3