Question

Is there a direct API to get the currently logged in user's name with the domain? So, it would return something like "domain\user" when a machine is on the domain, but at the same time it would return "user" when the machine is not on the domain? If there's not, what's the best way to get this information?

I noticed there's a LookupAccountName function - would that be the right direction to take?

Was it helpful?

Solution

Try GetUserNameEx(). It supports various name formats.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top