我不明白此错误(LPCWSTR)

0 c++

嗨,我只在尝试启动C时为植物大战僵尸教练编写代码,但由于以下错误而失败:

错误:无法将参数'2'的'LPCWSTR {aka const wchar_t *}'转换为'LPCSTR {aka const char *}'到'HWND __ * FindWindowA(LPCSTR,LPCSTR)'|

这是我的代码:

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    system("color 0A");//change the colour of the text
    cout << "PlantsVsZombies Trainer voor game of the year edition(gemaakt door Pjotr Slooff)" << endl;//display some (dutch) text
    cout << "Open PlantsVsZombies en druk dan op enter" << endl;
    system("Pause");//wait for the user to press enter
    LPCWSTR Game = L"Plants vs. Zombies";
    HWND hwnd = FindWindowA(0, Game);
    if (hwnd == 0)
    {
            cout << "PlantsVsZombies is niet gevonden open het en probeer het dan opnieuw" << endl;
            system("Pause");
    }
    else
    {
            DWORD process_ID;
            GetWindowThreadProcessId(hwnd, &process_ID);
            HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, process_ID);
            cout << "PlantsVsZombies is gevonden! Happy Hacking :D" << endl;
            system("Pause");
            cout << "Typ 1 voor Zon Cheat" << endl;
            cout << "Typ: ";
            int Option;
            cin >> Option;
            if (Option > 1)
            {
                    cout << "Er is maar 1 optie" << endl;
                    system("Pause");
            }
            if (Option == 1)
            {
                    cout << "Hoeveel Zon wil je?" << endl;
                    cout << "Typ: ";
                    int Zon;
                    cin >> Zon;
                    DWORD newdatasize = sizeof(Zon);
                    if (WriteProcessMemory(hProcess, (LPVOID)00005560, &Zon, newdatasize, NULL))
                    {
                            cout << "De Zon is toegevoegd" << endl;
                            system("Pause");
                    }
                    else
                    {
                            cout << "Er was een error tijdens het toevoegen van de Zon" << endl;
                            system("Pause");
                    }

            }
    }
    main();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我发现这非常令人anny异,无法解决,因此我非常感谢谁回答了我的问题

mar*_*inj 5

代替FindWindowA(0, Game);使用FindWindowW(0, Game);,或简单地FindWindow

FindWindowA接受错误的LPCSTR参数,并且您正在传递LPCWSTR