There is an API function you can use. Here's a wrapper function for that API function.VB Code:
Private Declare Function GetComputerName _ Lib "kernel32.dll" Alias "GetComputerNameA" ( _ ByVal lpBuffer As String, _ ByRef nSize As Long) As Long Public Function GetCompName() As String Dim sBuff As String Dim nLen As Long nLen = 215 'probably to large buffer sBuff = Space$(nLen + 1) If GetComputerName(sBuff, nLen) Then GetCompName = Left$(sBuff, nLen) Else sBuff = Space$(nLen) Call GetComputerName(sBuff, nLen) GetCompName = Left$(sBuff, nLen) End If End Function




Reply With Quote