LPTSTR
is defined as TCHAR*
. What you want is a const pointer. You can use LPCTSTR
, which is defined as TCHAR const*
:
LPCTSTR process_name = TEXT("rFactor2.exe");
If your function requires a non-const pointer, you can create a copy:
TCHAR process_name[] = TEXT("rFactor2.exe");
Note that life time of the string literal and the array are not the same.
it's the type that GetModuleBase
expects
Considering you are working with legacy code, it is possible that your functions take non-const pointers and don't modify them. If you are certain about that and can't go ahead and fix those function signatures to be const-correct, you can use a type cast. Do this only as a last resort:
auto process_name = const_cast<LPTSTR>(TEXT("rFactor2.exe"));
Recommended reading:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…