I’m currently modifying a credential provider for Windows 7, in C++. The Windows SDK requires use of PWSTR.
I’ve hit a problem where the username is sometimes being passed as DOMAIN\username and sometimes as domain.tld\username and sometimes just username. What I’d like to do is extract the username from this, and only take the substring after the slash.
I’m new to C++ and none of the string functions appear to work with PWSTR. I’ve tried a few conversions to wchar_t* but it’s still not getting me anywhere.
How can this be achieved?
TIA
You could do something like:
Note this doesn’t do a separate memory allocation – the thing you return is the pointer to the part of the string beginning after the last slash. If you were to do a proper “substring” operation like you might see in higher-level objects (instead of just taking
len - istarting at offseti) you’d have to do a copy (or somehow track that you’re only considering a smaller length).