I'm trying to use FindWindow() from WinAPI, and I want to ask an input for window's title from the user:
char *input;
cout << "Window title: ";
cin >> input;
Pretty standard.
Now then, how do I convert this to LPCWSTR for FindWindow()?
I've already tried the following: _T(input), TEXT(input), (LPCWSTR)input but none of them worked.
I also tried using wchar_t instead of char, but I need char everywhere else so then I get dozens of errors for using wchar_t instead of char...
You can use the wide variants of cin and cout:
wchar_t input[256]; // don't really use a fixed size buffer!
wcout << L"Window title: ";
wcin >> input;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With