Home

Created By Wesley Griffin

 
 
 Retrieve Computer Name.
 
  Home > Source CodeSystem/API > Computer Name
 
  Place the following code into the code window of a form:
 
 
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
 
Private Function MyComputerName() as String
     Dim dwLen As Long
     Dim strString As String
     dwLen = MAX_COMPUTERNAME_LENGTH + 1
     strString = String(dwLen, "X")
     GetComputerName strString, dwLen
     MyComputerName = Left(strString, dwLen)
End Function
 
 

 Top.

 
  Warning:
All material from this site must be used at own risk.  VB First Aid will take no responsibility for any loss of data or any other errors.  The material on this site was written for Visual Basic Version 6, therefore compatibility with other versions may cause errors.