【方法一——最简单】在 工程菜单的部件里找到 Microsoft Winsock Control 然后添加。。它就显示在工具栏上winsock1.LocalHostName 【方法二——最正统】Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
创新互联长期为近1000家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为昆都仑企业提供专业的网站制作、网站设计,昆都仑网站改版等技术服务。拥有十年丰富建站经验和众多成功案例,为您定制开发。
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然后调用这个函数即可
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub GetName()
Dim sJM As String
Dim sMC As String
Dim sIP As String
Dim s As String
s = String(128, Chr(0))
GetComputerName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sJM = s'计算机名称
s = String(128, Chr(0))
GetUserName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sMC = s‘当前用户名称
End Sub
'用这种方法在远程获得再发回本机就可以吧
'取计算机型号暂时不会
My功能可以替代很多API,因为CLR已经封装了大量系统函数,不建议使用API,那样会限制程序的可移植性。(微软声称.NET FRAMEWORK是跨平台的,但是迄今都没看见在Linux上的.NET 程序)
多翻翻MSDN就知道东西怎么用了