Declare Function GetComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
GetComputerName reads the name of the user's computer. I'm not certain, but I think this may be the computer's name on the network (I don't have a newtworked computer, so I may be wrong). The name is put into the string variable passed as lpBuffer. The function returns 0 if an error occured, or a non-zero value if successful.
Example:
Dim compname As String * 255, cname As String ' more than long enough
' Read the computer's name
x = GetComputerName(compname, 255)
' Trim blank spaces and ending vbNullChar
cname = Trim(compname)
cname = Left(cname, Len(cname) - 1)
Debug.Print "My name is " cname
Category: System Information
Back to the index.