请问如何获取设备ID? RRS feed

  • Question

  • 我在VS2008下用的vb.net开发WM6程序,想获取设备的ID。参照网上一片文章写了个方法,但运行时会报错。代码如下:

    Imports Microsoft.SmartDevice.Connectivity

        Public Function GetDeviceCode() As String
            ' Get the datastore object
            Dim dsmgr As New DatastoreManager(1033)
            ' Get the platform object
            Dim platform As Platform = GetPlatformByName("Windows Mobile 6.0 Professional SDK", dsmgr)
                ' Get the default device in the platform, usually an emulator.
                Dim myDevice As Device = platform.GetDevice(platform.GetDefaultDeviceId())
                Return myDevice.Id.ToString
            Catch ex As Exception
                Return "error"
            End Try

        End Function

        Private Function GetPlatformByName(ByVal p As String, _
                                                  ByVal dsmgr As DatastoreManager) As Platform
            ' Get all platforms in the datastore.
            Dim platforms As System.Collections.ObjectModel.Collection(Of Platform) = dsmgr.GetPlatforms()

            ' Find the platform whose name matches the parameter.
            For Each pf As Platform In platforms
                If pf.Name = p Then
                    Return pf
                End If
            Next pf
            Return Nothing
        End Function

    错误如下:未能从程序集“Microsoft.SmartDevice.Connectivity, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A”中加载类型“Microsoft.SmartDevice.Connectivity.DatastoreManager”。


    Tuesday, June 1, 2010 9:56 AM


All replies