Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Declare Function LookupAccountName Lib "advapi32.dll" Alias "LookupAccountNameA" (lpSystemName As String, ByVal lpAccountName As String, sid As Any, cbSid As Long, ByVal ReferencedDomainName As String, cbReferencedDomainName As Long, peUse As Long) As Long Private Sub Form_Load() Dim sDomainName As String * 255 Dim lDomainNameLength As Long Dim sUserName As String Dim bUserSid(255) As Byte Dim lSIDType As Long ' Create a buffer sUserName = String(100, Chr$(0)) ' Get the username GetUserName sUserName, 100 'strip the rest of the buffer sUserName = Left$(sUserName, InStr(sUserName, Chr$(0)) - 1) ' Show the temppath and the username MsgBox "Hello " + strUserName lResult = LookupAccountName(vbNullString, sUserName, bUserSid(0), 255, sDomainName, lDomainNameLength, _ lSIDType) If lResult <> 0 Then MsgBox sDomainName End If End Sub