Did a C-like thing which does work in its current form, but certainly more clunky than the methods shown above:
#include <windows.h>
void main ()
{
int i;
wchar_t searchString[100];
wchar_t * stringReturn;
memset(searchString, L'\0', sizeof(stringReturn));
wcscpy_s(searchString, 100, L"String\\ to search");
stringReturn = wcschr (searchString, '\\');
if (stringReturn)
{
for (i = 0; i < (int)(stringReturn - searchString); i++) stringReturn[i] = searchString[i];
stringReturn[i] = L'\0';
wcscpy_s(searchString, 100, stringReturn);
}
}
Can be easily modified to work for dynamic strings.