-1

I keep getting this error message: HWND FindWindowExW(HWND,HWND,LPCWSTR,LPCWSTR)': cannot convert argument 3 from 'const char [6]' to 'LPCWSTR

This is my code below. Anyone fix the error for me?


using namespace std;

INPUT Key;
HWND Find;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE thread_binds;
HANDLE thread_armor;

int width, height;
int slotsX, slotsY1, slotsY2, slotsY3, slotsY4, invY1, invY2, invX1, invX2;
int thirdkey, fourthkey, fifthkey, sixthkey;

RECT rect;

HWND search()
{
    Find = FindWindowEx(0, 0, "LWJGL", 0);
    return Find;
}

HANDLE GetHandle()
{
    return hConsole;
}

I'm really looking for an answer, thx

tomas
  • 1
  • Since you have your project set to use Unicode you need to use wide strings, so `L"LWJGL"`. – Retired Ninja Aug 12 '21 at 09:10
  • Can u send the code without that error please – tomas Aug 12 '21 at 09:25
  • Literally that. Put a `L` in front of your string. Better yet, use [`TEXT("LWJGL")`](https://stackoverflow.com/questions/15498070/what-does-t-stands-for-in-a-cstring) instead, which automatically adds or elides the `L` depending on the value of the UNICODE preprocessor symbol. – Botje Aug 12 '21 at 09:31
  • Thx a lot, i Fix it – tomas Aug 12 '21 at 09:37

1 Answers1

0

Windows always provides two functions that take a string.

In your case you can use FindWindowExA (A for ANSI) which takes a simple char* string.

The W functions like FindWindowExW (W for Wide) takes wide char strings of type wchar_t.

Raildex
  • 3,406
  • 1
  • 18
  • 42
  • This does not answer OP's question: you should at least explain which variant `FindWindowEx` maps to and how to change the argument type. – Botje Aug 12 '21 at 09:30