Get computer name : Windows User « Windows API « VBA / Excel / Access / Word






Get computer name

 
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, ByRef nSize As Long) As Long
Private Function 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 Function
Sub ComputerCheck()
    Debug.Print ComputerName
End Sub

 








Related examples in the same category

1.Retrieve USERID