Text String Conversions

Hello.
I have the following piece of code:

while(retval) {
if(strcmp((char*)pe.szExeFile, procName)==0 ){
ProcFound = true;
break;
}
cout<<(char*)pe.szExeFile<<endl;
retval = Process32Next(thSnapshot,&pe);
pe.dwSize = sizeof(PROCESSENTRY32);
}

Stuff works fine up until the point where i output the name of the file. IN that case it just gives me the first letter of the file, and not the whole name.
Any ideas why?
Thx
[545 byte] By [Quell] at [2007-11-19 23:17:42]
# 1 Re: Text String Conversions
The docs say that all strings in the PROCESSENTRY32 function are unicode, but you treat them like ANSI strings.
philkr at 2007-11-9 1:04:41 >
# 2 Re: Text String Conversions
It seems your are compiling your code in Unicode mode, but are trying to work with ANSI string. See the value of Project Properties --> General --> Character Set option.

Either switch to ANSI mode, or change your program for Unicode mode:

while(retval) {
if(wcscmp(pe.szExeFile, procName)==0 ){
ProcFound = true;
break;
}
wcout<<pe.szExeFile<<endl;
retval = Process32Next(thSnapshot,&pe);
pe.dwSize = sizeof(PROCESSENTRY32);
}
But it would be better to make your program work in both Unicode and ANSI modes. This requires some adjustments in your program.
Viorel at 2007-11-9 1:05:38 >
# 3 Re: Text String Conversions
I never knew the diffrence, but now that i am stuck, i am reading some FAQS on here and it is making it alot better.Thanks for pointing me in the write direction.
Quell at 2007-11-9 1:06:36 >
# 4 Re: Text String Conversions
Can you check your project settings->C++ tab ?

Let us know if there is _UNICODE in preprocessor definations.
Krishnaa at 2007-11-9 1:07:37 >