Thanks for your hints, Paul.
I added some tests for the Ansi variant of the function and fixed the problem you mentioned.
I also think that your addition of _GetAccountNameFromTokenW is holding the committing of this patch back, especially because you don't seem to use
that
function.
I also added an additional comment, why this function is not used. Maybe you didn't notice the comments later on. Hopefully this makes things clearer. Unfortunately I don't have enough knowledge to fix the LookupAccountSidW which is the reason why I did not use it, and why I'm still using GetUserName to make the function return a valid path.
Is it regarded bad style what I did here? Any suggestions otherwise?
Regards Andreas