Current user? API vs Registry

  • Thread starter Thread starter Tim Bedford
  • Start date Start date
T

Tim Bedford

Hi,
I need to get the name of the user currently interactively logged on. I've
got two solutions:
Read the value held in HKLM\\SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\Winlogon\\DefaultUserName or:
Get the last name read from a call to NetWkstaUserEnum.
Which is the better bet?
I haven't seen it confirmed in any Microsoft documentation that the last
value from NetWkstaUserEnum will always be the currently logged on user but
testing it suggests that this is the case. But I've also seen it mentioned
that storing the current username in the Registry can be disabled (How is
this done? Is it an admin only thing?).
thanks,

Tim
 
Back
Top