移动设备 MAC 地址

发布于 2024-12-01 10:04:42 字数 145 浏览 0 评论 0原文

我有一个 Windows Mobile 项目。我想获取设备的 MAC 地址或号码以确保我的软件的安全。我的项目是Windows Ce和Windows Mobile 6(两个项目)。如何从移动设备获取价值? (我看了同样的问题,但它们是关于蓝牙 MAC 地址的,有些设备没有它)

I have a windows mobile project.I want to get the MAC address or numbers of the device for securitiy of my software. My project is in Windows Ce and Windows Mobile 6 (two project). How can I get the value from the mobile device? (I looked the same questions but they are about Bluetooth MAC address and some devices don't have it)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滥情稳全场 2024-12-08 10:04:42

调用 GetAdaptersInfo API。它返回一个 IP_ADAPTER_INFO 这是一个缓冲区设备适配器的所有信息。 IP_ADAPTER_INFO 包含一个名为 Address 的成员,它是适配器的 MAC 地址。

Call the GetAdaptersInfo API. It returns an IP_ADAPTER_INFO which is a buffer of all infos for the device's adapters. The IP_ADAPTER_INFO contains a member called Address which is the adapter's MAC address.

ゝ偶尔ゞ 2024-12-08 10:04:42

由于我花了很多时间来找到 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

Since I take a lot time to find a VB.NET way to this,so I post this for anyone that could be useful.

<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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文