I currently use the following code to get the User name of the logged in user.
But what I want to do is get the long name.Code:Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _ (ByVal lpBuffer As String, nSize As Long) As Long Public Function CurrentUser() As String '* Function to get the current logged on user in windows * Dim strBuff As String * 255 Dim x As Long CurrentUser = "" x = GetUserName(strBuff, Len(strBuff) - 1) If x > 0 Then 'Look for Null Character, usually included x = InStr(strBuff, vbNullChar) 'Trim off buffered spaces too If x > 0 Then CurrentUser = Left$(strBuff, x - 1) 'UCase is optional Else CurrentUser = Left$(strBuff, x) End If End If End Function
Thus if the user login name is smitty I could retrieve the long name of Yolanda Smitt
I have already checked out RobDog's How do I get the current windows user name?





Reply With Quote