Public Function GetComputerName() As String
Dim ComputerName As String
ComputerName = System.Net.Dns.GetHostName
Return ComputerName
End Function
答案 0 :(得分:2)
对于PC名称使用:
My.Computer.Name
供IP使用:
Private Sub GetIPAddress()
Dim strHostName As String
Dim strIPAddress As String
strHostName = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.GetHostByName(strHostName).AddressList(0).ToString()
MessageBox.Show("Host Name: " & strHostName & "; IP Address: " & strIPAddress)
End Sub