How to get logged-in user's full name in windows?

后端 未结 6 2078
借酒劲吻你
借酒劲吻你 2020-11-30 13:07

How to get logged-in user\'s full name (the one he/she entered as his/her real name) using windows API or something else? For example how to get \"John Smith\", not \"john\"

6条回答
  •  我在风中等你
    2020-11-30 13:32

    I have found some places in windows registry with my email or my full name:

    1. HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo has UserName which contains my full name.
    2. KEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer has Logon User Name which contains my email.
    3. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon has DefaultUserName which contains my email.

    The first one obviously requires Microsoft Office to be installed and that the user has entered his/her name in the Office settings. The second and the third are more reliable but contains email instead but email is also good (or better) identification than full name.

提交回复
热议问题