如何以字符串格式(实际格式)获取mac地址 [英] how to get mac address in string format(actual format )
本文介绍了如何以字符串格式(实际格式)获取mac地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何在asp.net中获取MAC地址
我看过一些文章,借助这些文章,我可以获得Mac地址
但它以"00114313D615"这种格式获取地址
但实际格式是这样的
"00-11-43-13-D1-65"
所以我怎么能获得实际格式的mac地址
How can we get MAC Address in asp.net
I have seen some articles and with the help of those article i can get mac address
but it gets address in "00114313D615" this format
but actual format is like this
"00-11-43-13-D1-65"
so how can i get mac address in actual format
推荐答案
Imports System.Management
Public Function GetSerial() As String
Dim mc As New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim mac As String = ""
Dim moc As ManagementObjectCollection = mc.GetInstances
For Each mo As ManagementObject In moc
If mo.Item("IPEnabled") Then
mac = mo.Item("MacAddress").ToString
End If
Next
mac = mac.Replace(":", "-")
Return mac
End Function
使用此代码...:)
Use this code......:)
这篇关于如何以字符串格式(实际格式)获取mac地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文