检测计算机名称 [英] detect the computer name
本文介绍了检测计算机名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我这里有问题。我需要在vb.net中的代码来检测计算机名称的IP地址.... tq
i have a problem here. i need code in vb.net to detect the computer name n the ip address....tq
推荐答案
你想如何获得PC名称,通过win form或aspx?
how do you want to get the PC name , by win form or aspx ?
通过
MsgBox(My.Computer.Name)
Private Function IPAddress() As String
Dim strIP As String = ""
Dim LocalHostName As String
Try
LocalHostName = Dns.GetHostName() ''Here u will get ur system Name
Dim ipEnter As IPHostEntry = Dns.GetHostEntry(LocalHostName)
Dim IpAdd() As IPAddress = ipEnter.AddressList
strIP = IpAdd(0).ToString()
Return strIP ''It will return ipaddress of ur system
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
并添加命名空间:
and add namespace:
Imports System.Net
这篇关于检测计算机名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文