Hi All,

I have done much web searching (and searched these forums) but I can't seem to find the solution to this;

I am wanting to resolve the current signed on users Name. I have the code to work out their ID number, but I want their actual name from this.

Is this possible please? A friend has passed me the perl code equivelent and its only a few lines.

Here is my current VB code;

VB Code:
  1. Private Declare Function GetUserNameAPI Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, _
  2.                                                             nSize As Long) As Long
  3.  
  4. Public Function GetUserName() As String
  5.     Dim sBuffer As String
  6.     Dim lSize As Long
  7.     Dim lRV As Long
  8.  
  9.     lSize = 255
  10.     sBuffer = String(lSize, &H0)
  11.      
  12.     lRV = GetUserNameAPI(sBuffer, lSize)
  13.    
  14.     If lRV <> 0 Then
  15.         GetUserName = Left(sBuffer, lSize - 1) ' -1 to remove trailing null character
  16.     Else
  17.         GetUserName = ""
  18.     End If
  19.    
  20. End Function
  21.  
  22.  
  23. Private Sub Command1_Click()
  24.  
  25. MsgBox GetUserName
  26.  
  27. End Sub

Any ideas?

Cheers!

Paul.