Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" ( _
ByVal lpBuffer As String, _
ByRef nSize As Long) As Long
Private Declare Function GetComputerName Lib "kernel32" _
Alias "GetComputerNameA" ( _
ByVal lpBuffer As String, _
ByRef nSize As Long) As Long
Public Property Get ComputerName() As String
Dim stBuff As String * 255, lAPIResult As Long
Dim lBuffLen As Long
lBuffLen = 255
lAPIResult = GetComputerName(stBuff, lBuffLen)
If lBuffLen > 0 Then ComputerName = Left(stBuff, lBuffLen)
End Property
Public Property Get UserName() As String
Dim stBuff As String * 255, lAPIResult As Long
Dim lBuffLen As Long
lBuffLen = 255
lAPIResult = GetUserName(stBuff, lBuffLen)
If lBuffLen > 0 Then UserName = Left(stBuff, lBuffLen - 1)
End Property