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

后端 未结 6 2070
借酒劲吻你
借酒劲吻你 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:43

    Well, if the user never entered it, there's no way for you to get it. You could look for installed email programs and politely ask them for the info, but that's a bad idea for many reasons.

    Here's your best shot: Get the name the user entered when registering the copy of Windows. This is in the registry. The exact location differs between Windows versions, but in recent versions, it's at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion (and in Windows 95/98/ME, at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion).

    In there, you'll find RegisteredOwner, which is where the was supposed to enter the name. Obviously, if this is a company computer and the machine was set up by IT, it's very common to find a standardized company string there. And, of course, lots of people will enter names there like "Joe Sixpack" or "Cracked by Quartex". However, that's as close as you can get.

提交回复
热议问题