views:

522

answers:

1

Hello all,

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?

Thanks in advance!

+2  A: 

Try GetUserNameEx(). It supports various name formats.

Ferruccio
Thank you - looks right.
dennisV