RSS订阅悠然探索,悠然索取
你的位置:首页 » 技术笔记 » 正文

VB.Net取得服务器的MAC地址

选择字号: 超大 标准 发布时间:2008-9-11 10:32:47 | 作者:admin | 0个评论 | 人浏览

Function CareFGetMac() As String
        Try
            Dim Mac As String
            Dim mc As ManagementClass
            mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
            Dim Moc2 As ManagementObjectCollection = mc.GetInstances
            Dim mo As ManagementObject
            For Each mo In Moc2
                If CBool(mo("IPEnabled")) = True Then
                    Mac += mo("MacAddress").ToString + "@"
                    Mac = mo("MacAddress").ToString
                End If
                'Mac = mo("MacAddress").ToString
            Next
            mo.Dispose()
            mc.Dispose()
            Moc2.Dispose()
            CareFGetMac = Mac
        Catch ex As Exception
            CareFGetMac = "00:E0:4C:77:1F:4A"
        End Try
    End Function

标签:VB.Net  MAC  

发表评论

必填

选填

选填

必填,不填不让过哦,嘻嘻。

记住我,下次回复时不用重新输入个人信息

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。