您好,我正在用 C++ 为植物大战僵尸训练器编写代码,只有当我尝试启动它时,它因以下错误而失败:
error: cannot convert 'LPCWSTR {aka const wchar_t*}' to 'LPCSTR {aka const char*}' for argument '2' to '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;
}
我觉得这很烦人,我无法解决它,所以我真的很感激谁能回答我的问题
最佳答案
代替 FindWindowA(0, Game);
使用 FindWindowW(0, Game);
,或者简单地 FindWindow
FindWindowA
错误地接受 LPCSTR 参数,而您正在传递 LPCWSTR
。
关于c++ - 我不明白这个错误 (LPCWSTR),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32074871/