You need to stop using char* and wchar_t*. Use the standard library strings. C-strings are evil™ in many ways.