Option Compare Database
'Dev Ashish
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngx As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngx = apiGetUserName(strUserName, lngLen)
If lngx <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function
|