Sign in to follow this  
nuclear123

problem with wide char string

Recommended Posts

[code]HANDLE pSnapList;
PROCESSENTRY32 p32Info;
BOOL p32Status;

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

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

}



};
[/code]




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!


Share this post


Link to post
Share on other sites
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"][size="3"]mbstowcs()[/size][/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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this