Hello...
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal sBuffer As String, lSize As Long) As Long
Private Declare Function w32_WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpszLocalName As String, ByVal lpszUserName As String, lpcchBuffer As Long) As Long
Public Function NameOfPC(MachineName As String) As Long
Dim NameSize As Long
Dim X As Long
MachineName = Space$(16)
NameSize = Len(MachineName)
X = GetComputerName(MachineName, NameSize)
If X <> 0 Then
MachineName = Left$(MachineName, InStr(1, MachineName, Chr$(0)) - 1)
End If
End Function
Public Function GetUser() As String
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim lpUserName As String, lpnLength As Long, lResult As Long
'Create a buffer
lpUserName = String(256, Chr$(0))
'Get the network user
lResult = w32_WNetGetUser(vbNullString, lpUserName, 256)
If lResult = 0 Then
lpUserName = Left$(lpUserName, InStr(1, lpUserName, Chr$(0)) - 1)
GetUser = lpUserName
End If
End Function
RicoNuch