Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal _ lpszLocalName As String, ByVal lpszUserName As String, _ lpcchBuffer As Long) As Long
Function NetworkUserName() As String Dim buffer As String buffer = Space$(256) If WNetGetUser(vbNullString, buffer, Len(buffer)) = 0 Then NetworkUserName = Left$(buffer, InStr(buffer, vbNullChar) - 1) End If End Function |