I have these lines of code in a command line project in VS2010 c++.
TCHAR name[30];
LPTSTR pname=&name[0];
std::wstring OutNumber;
pname = &name[0];
GetWindowText(hGameNumber,pname,30);
works fine without problems.
No I’m using the same lines in a Qt widget base application using Qt Creator. When compiling it I get the error:
“error: C2440: ‘initializing’ : cannot convert from ‘TCHAR *’ to ‘LPTSTR’
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast”
Thanks for any help, Lumpi
cast, as in
LPTSTR pname = reinterpret_cast<LPTSTR>(&name[0]);and all will be well. also remove the line that reads
pname = &name[0];right after you create the std::wstring object.