Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Processentry32

Tags:

c++

char

wchar

please help.

PROCESSENTRY32 entry; if (!strcmp(entry.szExeFile, process))

Error on entry: Argument of type WCHAR* is incompatible with parametr of type const char*

Please dont hate me, I am beginer.

Thanks for helping ;)

like image 209
Dortík Avatar asked Oct 27 '25 05:10

Dortík


1 Answers

You defined UNICODE in code somewhere or in project settings.

So PROCESSENTRY32 is unicode version, but you use ASCII version of strcmp

The solution is to use another function

#include <wchar.h>
...
if (!wcscmp(entry.szExeFile, process))

or Windows-only ( WinApi function )

#include <windows.h>
...
if (!lstrcmpW(entry.szExeFile, process))

Note that process variable must be wchar_t* or LPWSTR type.

For example:

#include <windows.h>
....

    wchar_t process[] = L"browser.exe"
    ...
    if (!lstrcmpW(entry.szExeFile, process))
like image 95
Solid Coder Avatar answered Oct 29 '25 18:10

Solid Coder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!