title: How do you read the user's display (first and last) name on all versions of Windows reliably?
body: <p>I have found that on Windows 7 64 bit, on a machine with a domain name, GetUserNameEx( 3, .... ) which should get the extended name format DisplayName (==3), into a buffer, works fine.</p>
  
  <p>However, it does not work on Windows 7 32 bit, vm that is on a workgroup, rather than on a domain, it returns ERROR_NONE_MAPPED.</p>
  
  <p>How do you read the person's friendly name "Fred Smith", for example, in a way that works on Windows? GetUserNameEx is manifestly broken. Actually, not broken, I'm told, just not intended to work for users who are not on a domain. Why not, I wonder, since the local SAM information exists? And there appears to be no other direct API to do this.</p>
  
  <p>If Windows gives you  ERROR_NONE_MAPPED, you are out of luck, and probably not on a domain.  So this is not exactly a friendly area of the API.</p>
  
  <p>[It is possible, it looks like, to call NetUserGetInfo, to read the local SAM info, when not on a domain, but you need to know the user name and password first, and then it will maybe look up the friendly name.]</p>
  
  <p><a href="https://stackoverflow.com/questions/3438634/how-to-get-logged-in-users-full-name-in-windows">RElated Question: does not mention the problem here</a></p>