![]() |
C++ String Comparison
I have connected to ROOT\\CIMV2 WMI namespace and after connecting run the following code.
Code:
IEnumWbemClassObject* pEnumerator = NULL;I want to get the process id for just the explorer process but I can not get the string comparison to work. I have tried the following: Code:
VARIANT vtProp;Why are these two not equal? I am new to C and am confused by all the different types of strings. The only modification is the query I ran. Thanks for your help |
Re: C++ String Comparison
They certainly look equal. Maybe one is plain ASCII and the other is Unicode? Have a look in memory* where the strings are stored, if one is effectively 'e' '\0' 'x' '\0'... and the other is 'e' 'x' 'p'... then you're trying to compare Unicode (the former) with ASCII (the latter) and this would correctly return "not equal", while appearing equal with both strings printed side by side.
*Either in the debugger, or get a void* pointer for each location and do a quick, say 32-byte, hex dump. |
Re: C++ String Comparison
whenever string code is like _T( " ") it means it's unicode.
So your code is using unicode so it's different than ASCII (As told by xpiOtOs) because in unicode one character's size will be 2 byte and in ASCII it's 1 byte.. |
Re: C++ String Comparison
Quote:
Where as _w is more specific macro specifying unicode. |
| All times are GMT +5.5. The time now is 19:49. |