Friend Class Form1 Inherits System.Windows.Forms.Form Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim theNetworkInterfaces() As System.Net.NetworkInformation.NetworkInterface = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() For Each currentInterface As System.Net.NetworkInformation.NetworkInterface In theNetworkInterfaces If currentInterface.OperationalStatus = Net.NetworkInformation.OperationalStatus.Up And currentInterface.NetworkInterfaceType.ToString() = "Ethernet" Then RichTextBox1.AppendText("MAC 地址 " & currentInterface.GetPhysicalAddress().ToString() & ControlChars.CrLf) RichTextBox1.AppendText("描述 " & currentInterface.Description.ToString() & ControlChars.CrLf) RichTextBox1.AppendText("名称 " & currentInterface.Name.ToString() & ControlChars.CrLf) RichTextBox1.AppendText("速度 " & currentInterface.Speed.ToString() & ControlChars.CrLf) RichTextBox1.AppendText("网络接口类型 " & currentInterface.NetworkInterfaceType.ToString() & ControlChars.CrLf) RichTextBox1.AppendText("运行状态 " & currentInterface.OperationalStatus.ToString() & ControlChars.CrLf) RichTextBox1.AppendText(ControlChars.CrLf) End If Next End Sub End Class
难道都没人知道怎么做吗?
在VB6下的代码我有,但是无法转到vb.net下
Friend Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim theNetworkInterfaces() As System.Net.NetworkInformation.NetworkInterface = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
For Each currentInterface As System.Net.NetworkInformation.NetworkInterface In theNetworkInterfaces
If currentInterface.OperationalStatus = Net.NetworkInformation.OperationalStatus.Up And currentInterface.NetworkInterfaceType.ToString() = "Ethernet" Then
RichTextBox1.AppendText("MAC 地址 " & currentInterface.GetPhysicalAddress().ToString() & ControlChars.CrLf)
RichTextBox1.AppendText("描述 " & currentInterface.Description.ToString() & ControlChars.CrLf)
RichTextBox1.AppendText("名称 " & currentInterface.Name.ToString() & ControlChars.CrLf)
RichTextBox1.AppendText("速度 " & currentInterface.Speed.ToString() & ControlChars.CrLf)
RichTextBox1.AppendText("网络接口类型 " & currentInterface.NetworkInterfaceType.ToString() & ControlChars.CrLf)
RichTextBox1.AppendText("运行状态 " & currentInterface.OperationalStatus.ToString() & ControlChars.CrLf)
RichTextBox1.AppendText(ControlChars.CrLf)
End If
Next
End Sub
End Class
有没有用API实现的方法呢?