if(wcscmp(sDisplayName, L"example") == 0) ; //then it contains "example" else ; //it does not
This does not apply if the line in sDisplayName starts with "example" or has an "example" in the middle. For these cases, you can use wcsncmp and wcsstr .
This check is also case sensitive.
Also, it will break if sDisplayName contains garbage - i. e. does not end with zero.
Use std :: wstring instead. This is a C ++ way.
EDIT: if you want to match the beginning of the line:
if(wcsncmp(sDisplayName, L"Adobe", 5) == 0) //Stars with "Adobe"
If you want to find the line in the middle
if(wcsstr(sDisplayName, L"Adobe") != 0) //Contains"Adobe"
Note that wcsstr returns a nonzero value if a string is found, unlike the others.
source share