Reputation: 67
I am using Visual Studio 2013. The error says "argument of type "WCHAR *" is incompatible with parameter of type "const char *".
while (!processId)
{
system("CLS");
cout << "Searching for game" << ProcessName << "..." << endl;
cout << "Make sure your game is running" << endl;
hProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (Process32First(hProcSnap, &pe32))
{
do
{
if (!strcmp(pe32.szExeFile, ProcessName))
{
processId = pe32.th32ProcessID;
break;
}
} while (Process32Next(hProcSnap, &pe32));
}
Sleep(1000);
}
The error is on the following line. On my ide it is on "pe32"
if (!strcmp(pe32.szExeFile, ProcessName))
Upvotes: 1
Views: 2043
Reputation: 4551
The signature of strcmp
is
int strcmp ( const char * str1, const char * str2 );
Whereas pe32.szExeFile
is a TCHAR[]
, which is either wchar_t[]
or char[]
depending on whether UNICODE
is defined. In your case, it is defined, so you need to either:
change ProcessName
to a wide character string and use wcscmp
to compare them.
use _tcscmp()
, and make sure ProcessName
is wide or narrow based on UNICODE
.
use the ANSI versions of the APIs, which have a capital A
appended to their names (e.g., Process32FirstA()
and Process32NextA()
).
Upvotes: 4