方法一:添加控件
在 工程菜单的部件里找到 Microsoft Winsock Control 然后添加。。它就显示在工具栏上winsock1.LocalHostName
方法二:调用函数
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As LongPublic Function GetComputer() As String
Dim strCompName As String
Dim intHandle As IntegerstrCompName = String(256, " ")
intHandle = GetComputerName(strCompName, 256)
strCompName = Left(strCompName, InStr(1, strCompName, Chr(0)) - 1)
GetComputer = Trim(strCompName)
End Function