【方法一——最简单】在 工程菜单的部件里找到 Microsoft Winsock Control 然后添加。。它就显示在工具栏上winsock1.LocalHostName 【方法二——最正统】Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public 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然后调用这个函数即可