我有一个 windows mobile 项目。我想获取设备的 MAC 地址或号码,以确保我的软件安全。我的项目在 Windows Ce 和 Windows Mobile 6(两个项目)。如何从移动设备获取价值?(我看了同样的问题,但它们是关于蓝牙 MAC 地址的,有些设备没有)
问问题
2518 次
2 回答
2
调用GetAdaptersInfo
API。它返回一个IP_ADAPTER_INFO
包含设备适配器所有信息的缓冲区。IP_ADAPTER_INFO
包含一个名为的成员,Address
它是适配器的 MAC 地址。
于 2011-08-26T13:08:05.720 回答
0
因为我花了很多时间来找到一个 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 If
于 2015-07-01T01:47:32.297 回答