Home > database >  C can't compile code using PROCESSENTRY32
C can't compile code using PROCESSENTRY32

Time:02-02

I'm trying to compile simple lines of code but I'm getting C2664 Error code.

#include <TlHelp32.h>

PROCESSENTRY32 pe32 = { 0 };

if (wcscmp(pe32.something, something) == 0) 

Error:

int wcscmp(const wchar_t *,const wchar_t *)': cannot convert argument 1 from 'CHAR [260]' to 'const wchar_t

The definition of wcscmp() is:

_Check_return_
_ACRTIMP int __cdecl wcscmp(
    _In_z_ wchar_t const* _String1,
    _In_z_ wchar_t const* _String2
    );

I can't use PROCESSENTRY32W because then Process32First() breaks because it needs PROCESSENTRY32.

How could I change this to make it compilable?

CodePudding user response:

Use PROCESSENTRY32W instead of PROCESSENTRY32.

Use Process32FirstW instead of Process32First.

  •  Tags:  
  • Related