[SOLVED] How to get User's Full Name lazarus / 34-Windows ---------------------------------------------------------------------- lazguy · 2017-11-28 18:01 Hello Everybody, I need to get the User's Full Name of the current logged user, not the Username. Not the result of SysUtils.GetEnvironmentVariable('USERNAME') Thank you very much in advance ---------------------------------------------------------------------- balazsszekely · 2017-11-28 18:34 GetUserNameEx( https://msdn.microsoft.com/en- us/library/windows/desktop/ms724435(v=vs.85).aspx )? You can find the declaration in unit JwaWindows. ---------------------------------------------------------------------- Remy Lebeau · 2017-11-28 20:59 I use GetUserNameEx() as well. If that fails, or is unavailable, I fallback to WMI instead.  I use GetUserName() and LookupAccountName() to get domain and username, and then query the FullName from the Win32_UserAccount table. Also look at NetGetUserInfo() with level=10 (other levels also have a full name as well). ---------------------------------------------------------------------- lazguy · 2017-11-28 22:06 Quote from: GetMem on November 28, 2017, 07:34:19 pmGetUserNameEx( https://msdn.microsoft.com/en- us/library/windows/desktop/ms724435(v=vs.85).aspx )? You can find the declaration in unit JwaWindows. Thank you very much GetMem. It worked ! ---------------------------------------------------------------------- lazguy · 2017-11-28 22:08 Quote from: Remy Lebeau on November 28, 2017, 09:59:00 pmI use GetUserNameEx() as well. If that fails, or is unavailable, I fallback to WMI instead.  I use GetUserName() and LookupAccountName() to get domain and username, and then query the FullName from the Win32_UserAccount table. Also look at NetGetUserInfo() with level=10 (other levels also have a full name as well). Thank you very much, Remy Lebeau. I used GetMem solution ---------------------------------------------------------------------- lazguy · 2017-11-29 13:20 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TForm1.GetUserNameExString(ANameFormat: DWORD): string;const  NameUnknown = 0; // Unknown name type.  NameFullyQualifiedDN = 1; // Fully qualified distinguished name  NameSamCompatible = 2; // Windows NT® 4.0 account name  NameDisplay = 3; // A "friendly" display name  NameUniqueId = 6; // GUID string that the IIDFromString function returns  NameCanonical = 7; // Complete canonical name  NameUserPrincipal = 8; // User principal name  NameCanonicalEx = 9;  NameServicePrincipal = 10; // Generalized service principal name  DNSDomainName = 11; // DNS domain name, plus the user namevar  Buf: array[0..256] of Char;  BufSize: DWORD;begin  Result := '';  BufSize := SizeOf(Buf) div SizeOf(Buf[0]);  if JwaWindows.GetUserNameEx(ANameFormat, @Buf[0], BufSize) then    Result := Buf;end;