What am I doing wrong?
When the project is set to "use unicode", the process.szExeFile field is of type WCHAR[]. The std::string class does not provide a constructor which accepts WCHAR[] (or wchar_t*) as input.
You are comparing a name variable as a non-Unicode string, so I assume you don't care about non-ASCII characters. If that is true, you may do this:
std::wstring exeStr(process.szExeFile);
std::string exeStrA(exeStr.begin(), exeStr.end());
if (exeStrA == string(name))
If you care about non-ASCII characters, you should do it the other way around, converting your name string to Unicode, for example using wsctombs() (you can find an example here: How do I convert a string to a wstring using the value of the string?).