求一段VB.NET调用API取得本机所有网卡MAC地址的代码,
声明:不要引用System.Management通过WMI来取MAC的
通过WMI的方式的某些XP系统上会出错谢谢!

解决方案 »

  1.   

    晕。
    难道都没人知道怎么做吗?
    在VB6下的代码我有,但是无法转到vb.net下
      

  2.   


    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
      

  3.   

    谢谢 aohan
    有没有用API实现的方法呢?