⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btpairingdlg.vb

📁 以前做NOKIA手机与PC通信时所参考的源代码,里面包括两个程序,一个是手机文件夹浏览源码,另一个手机SIS安装程序.
💻 VB
📖 第 1 页 / 共 2 页
字号:
'Filename    : BTPairingDlg.vb
'Part of     : Phone Navigator VB.NET example
'Description : Dialog for pairing Bluetooth devices
'Version     : 3.2
'
'This example is only to be used with PC Connectivity API version 3.2.
'Compability ("as is") with future versions is not quaranteed.
'
'Copyright (c) 2005-2007 Nokia Corporation.
'
'This material, including but not limited to documentation and any related
'computer programs, is protected by intellectual property rights of Nokia
'Corporation and/or its licensors.
'All rights are reserved. Reproducing, modifying, translating, or
'distributing any or all of this material requires the prior written consent
'of Nokia Corporation. Nokia Corporation retains the right to make changes
'to this material at any time without notice. A copyright license is hereby
'granted to download and print a copy of this material for personal use only.
'No other license to any other intellectual property rights is granted. The
'material is provided "as is" without warranty of any kind, either express or
'implied, including without limitation, any warranty of non-infringement,
'merchantability and fitness for a particular purpose. In no event shall
'Nokia Corporation be liable for any direct, indirect, special, incidental,
'or consequential loss or damages, including but not limited to, lost profits
'or revenue,loss of use, cost of substitute program, or loss of data or
'equipment arising out of the use or inability to use the material, even if
'Nokia Corporation has been advised of the likelihood of such damages occurring.

Imports System.Runtime.InteropServices

Public Class FRM_BTPairing
    Inherits System.Windows.Forms.Form

    Private Structure BTDevice
        Dim strName As String
        Dim strAddress As String
        Dim iDeviceID As Integer
        Dim iStatus As Integer
    End Structure

    Private m_bDisposed As Boolean = False
    Private m_hDMHandle As Integer ' Device management handle
    Private m_pDevices() As BTDevice
    Private m_pfnSearchNotify As SearchCallbackDelegate
    Private m_pProgressDlg As FRM_ProgressDlg

#Region " Windows Form Designer generated code "

    '===================================================================
    ' Constructor
    '
    '===================================================================
    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

        ' Get Device management handle
        Dim iRet As Integer = CONAOpenDM(m_hDMHandle)
        If iRet <> CONA_OK Then ShowErrorMessage("CONAOpenDM", iRet)
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If Not m_bDisposed Then
            MyBase.Dispose(disposing)
        End If
        m_bDisposed = True
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents BTN_Close As System.Windows.Forms.Button
    Friend WithEvents BTN_Search As System.Windows.Forms.Button
    Friend WithEvents BTN_Pair As System.Windows.Forms.Button
    Friend WithEvents BTN_Unpair As System.Windows.Forms.Button
    Friend WithEvents BTN_SetTrusted As System.Windows.Forms.Button
    Friend WithEvents BTN_SetUnTrusted As System.Windows.Forms.Button
    Friend WithEvents LVW_PhoneList As System.Windows.Forms.ListView
    Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader
    Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(FRM_BTPairing))
        Me.LVW_PhoneList = New System.Windows.Forms.ListView
        Me.BTN_Close = New System.Windows.Forms.Button
        Me.BTN_Search = New System.Windows.Forms.Button
        Me.BTN_Pair = New System.Windows.Forms.Button
        Me.BTN_Unpair = New System.Windows.Forms.Button
        Me.BTN_SetTrusted = New System.Windows.Forms.Button
        Me.BTN_SetUnTrusted = New System.Windows.Forms.Button
        Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader
        Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader
        Me.SuspendLayout()
        '
        'LVW_PhoneList
        '
        Me.LVW_PhoneList.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader2})
        Me.LVW_PhoneList.FullRowSelect = True
        Me.LVW_PhoneList.Location = New System.Drawing.Point(8, 8)
        Me.LVW_PhoneList.Name = "LVW_PhoneList"
        Me.LVW_PhoneList.Size = New System.Drawing.Size(272, 136)
        Me.LVW_PhoneList.TabIndex = 0
        Me.LVW_PhoneList.View = System.Windows.Forms.View.Details
        '
        'BTN_Close
        '
        Me.BTN_Close.Location = New System.Drawing.Point(288, 8)
        Me.BTN_Close.Name = "BTN_Close"
        Me.BTN_Close.Size = New System.Drawing.Size(80, 24)
        Me.BTN_Close.TabIndex = 7
        Me.BTN_Close.Text = "Close"
        '
        'BTN_Search
        '
        Me.BTN_Search.Location = New System.Drawing.Point(8, 160)
        Me.BTN_Search.Name = "BTN_Search"
        Me.BTN_Search.Size = New System.Drawing.Size(88, 24)
        Me.BTN_Search.TabIndex = 8
        Me.BTN_Search.Text = "Refresh List"
        '
        'BTN_Pair
        '
        Me.BTN_Pair.Location = New System.Drawing.Point(104, 160)
        Me.BTN_Pair.Name = "BTN_Pair"
        Me.BTN_Pair.Size = New System.Drawing.Size(80, 24)
        Me.BTN_Pair.TabIndex = 9
        Me.BTN_Pair.Text = "Pair"
        '
        'BTN_Unpair
        '
        Me.BTN_Unpair.Location = New System.Drawing.Point(104, 192)
        Me.BTN_Unpair.Name = "BTN_Unpair"
        Me.BTN_Unpair.Size = New System.Drawing.Size(80, 24)
        Me.BTN_Unpair.TabIndex = 10
        Me.BTN_Unpair.Text = "Unpair"
        '
        'BTN_SetTrusted
        '
        Me.BTN_SetTrusted.Location = New System.Drawing.Point(192, 160)
        Me.BTN_SetTrusted.Name = "BTN_SetTrusted"
        Me.BTN_SetTrusted.Size = New System.Drawing.Size(88, 24)
        Me.BTN_SetTrusted.TabIndex = 11
        Me.BTN_SetTrusted.Text = "Set Trusted"
        '
        'BTN_SetUnTrusted
        '
        Me.BTN_SetUnTrusted.Location = New System.Drawing.Point(192, 192)
        Me.BTN_SetUnTrusted.Name = "BTN_SetUnTrusted"
        Me.BTN_SetUnTrusted.Size = New System.Drawing.Size(88, 24)
        Me.BTN_SetUnTrusted.TabIndex = 12
        Me.BTN_SetUnTrusted.Text = "Set Untrusted"
        '
        'ColumnHeader1
        '
        Me.ColumnHeader1.Text = "Phone name"
        Me.ColumnHeader1.Width = 134
        '
        'ColumnHeader2
        '
        Me.ColumnHeader2.Text = "Status"
        Me.ColumnHeader2.Width = 134
        '
        'FRM_BTPairing
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(378, 224)
        Me.Controls.Add(Me.BTN_SetUnTrusted)
        Me.Controls.Add(Me.BTN_SetTrusted)
        Me.Controls.Add(Me.BTN_Unpair)
        Me.Controls.Add(Me.BTN_Pair)
        Me.Controls.Add(Me.BTN_Search)
        Me.Controls.Add(Me.BTN_Close)
        Me.Controls.Add(Me.LVW_PhoneList)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "FRM_BTPairing"
        Me.Text = "Bluetooth Pairing"
        Me.ResumeLayout(False)

    End Sub

#End Region

    '===================================================================
    ' BTPairingNotifyCallback
    '
    ' BT device searching callback funtion. Shows the progress dialog
    ' at the beginning of search and sets the progress dialog progress
    ' bar to correct position.
    ' If function m_pProgressDlg.IsCancelled returns TRUE, this
    ' function returns ECONA_CANCELLED, and connectivity API stops
    ' the device search.
    ' In other situations this function must always return CONA_OK.
    '===================================================================
    Public Function BTPairingNotifyCallback(ByVal iState As Integer, ByVal pConnInfoStructure As IntPtr) As Integer
        BTPairingNotifyCallback = CONA_OK
        ' iState value grows from 0 to 100
        If iState < 100 Then
            If m_pProgressDlg Is Nothing Then
                ' Start progress dialog
                m_pProgressDlg = New FRM_ProgressDlg
                m_pProgressDlg.Show()
            End If

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -