problem with wide char string

Started by
0 comments, last by frob 13 years, 2 months ago
HANDLE pSnapList;
PROCESSENTRY32 p32Info;
BOOL p32Status;

pSnapList = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
p32Info.dwSize = sizeof( PROCESSENTRY32 );

p32Status = Process32First( pSnapList, &p32Info );
while( Process32Next( pSnapList, &p32Info ) )
{
if( !strcmp( p32Info.szExeFile, processName.c_str() ) )
{
processID = p32Info.th32ProcessID;
return;

}



};





error C2664: 'strcmp' : cannot convert parameter 1 from 'WCHAR [260]' to 'const char *'

i hav no idea how to compare these 2 strings of different types. Any advice is greatly appreciated!


Advertisement
You need to convert from one string type to another before you can compare them. The easier conversion is to convert the char string to a wide char string. Use [font="monospace"]mbstowcs()[/font] to convert it. Then you can use a wide string compare.

Also, consider why you are using the two types of string format. You might also look at changing your compiler options to give you wide strings by default, or just call the wide string versions to begin with.

This topic is closed to new replies.

Advertisement