GetComputerName




Public Function GetComputerName() As String
'

' This routine will obtain the Computers name from the system. The

' second time it is called it returns the static 'sName' variable

'

Static sName As String
Dim lBuffLen As Long
Dim sBuffer As String
Dim lRet As Long

If Len(sName) > 0 Then
GetComputerName = sName
Exit Function
Else
lBuffLen = 128
sBuffer = String$(lBuffLen, vbNullChar)
lRet = GetComputerName(sBuffer, lBuffLen)
If lRet < 0 Then
'

' Handle API error Here

'

Exit Function
End If
sName = Left$(sBuffer, lBuffLen)
GetComputerName = sName
End If
End Function










( getcomputername.html )- by Paolo Puglisi - Modifica del 17/12/2023