我有一个windows mobile项目,我想得到设备的MAC地址或号码,以确保我的软件安全。我的项目是Windows Ce和Windows Mobile6(两个项目)。如何从移动设备获取价值?(我看了同样的问题,但它们是关于蓝牙MAC地址的,有些设备没有)
发布于 2011-08-26 21:08:06
调用GetAdaptersInfo接口。它返回一个IP_ADAPTER_INFO,它是设备适配器的所有信息的缓冲区。IP_ADAPTER_INFO包含一个名为Address的成员,它是适配器的MAC地址。
发布于 2015-07-01 09:47:32
因为我花了很多时间找到一个VB.NET的方法来解决这个问题,所以我把这篇文章发布给任何可能有用的人。
<DllImport("iphlpapi.dll", SetLastError:=True)> _
Public Shared Function GetAdaptersInfo(ByVal info As Byte(), ByRef size As UInteger) As Integer
End Function
Public Shared Function GetMacAddress() As String
Dim num As UInteger = 0UI
GetAdaptersInfo(Nothing, num)
Dim array As Byte() = New Byte(CInt(num) - 1) {}
Dim adaptersInfo As Integer = GetAdaptersInfo(array, num)
If adaptersInfo = 0 Then
Dim macAddress As String = ""
Dim macLength As Integer = BitConverter.ToInt32(array, 400)
macAddress = BitConverter.ToString(array, 404, macLength)
macAddress = macAddress.Replace("-", ":")
Return macAddress
Else
Return ""
End Ifhttps://stackoverflow.com/questions/7201170
复制相似问题