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

📄 form1.vb

📁 VB通过调用RAPI来实现PC远程控制PDA,实现PDA与PC的数据拷贝,修改和粘贴等等功能
💻 VB
字号:
Imports OpenNETCF.Desktop.Communication

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private WithEvents m_rapi As RAPI
    Private WithEvents m_activesync As ActiveSync

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

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

        ' create the RAPI object
        m_rapi = New RAPI

        ' get its ActiveSync member
        m_activesync = m_rapi.ActiveSync
    End Sub


    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    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 btnConnect As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents lblStatus As System.Windows.Forms.Label
    Friend WithEvents txtInfo As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnConnect = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.lblStatus = New System.Windows.Forms.Label
        Me.txtInfo = New System.Windows.Forms.TextBox
        Me.SuspendLayout()
        '
        'btnConnect
        '
        Me.btnConnect.Location = New System.Drawing.Point(12, 12)
        Me.btnConnect.Name = "btnConnect"
        Me.btnConnect.Size = New System.Drawing.Size(100, 32)
        Me.btnConnect.TabIndex = 0
        Me.btnConnect.Text = "Connect"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(12, 248)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(100, 20)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "ActiveSync Status:"
        '
        'lblStatus
        '
        Me.lblStatus.Location = New System.Drawing.Point(112, 248)
        Me.lblStatus.Name = "lblStatus"
        Me.lblStatus.Size = New System.Drawing.Size(100, 20)
        Me.lblStatus.TabIndex = 2
        Me.lblStatus.Text = "Unknown"
        '
        'txtInfo
        '
        Me.txtInfo.Location = New System.Drawing.Point(12, 56)
        Me.txtInfo.Multiline = True
        Me.txtInfo.Name = "txtInfo"
        Me.txtInfo.Size = New System.Drawing.Size(248, 176)
        Me.txtInfo.TabIndex = 3
        Me.txtInfo.Text = ""
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(284, 273)
        Me.Controls.Add(Me.txtInfo)
        Me.Controls.Add(Me.lblStatus)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.btnConnect)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
        If Not m_rapi.Connected Then
            m_rapi.Connect()
            btnConnect.Text = "Disconnect"

            Dim si As New SYSTEM_INFO
            Dim vi As New OSVERSIONINFO
            Dim sps As New SYSTEM_POWER_STATUS_EX
            Dim ms As New MEMORYSTATUS

            Dim info As String

            m_rapi.GetDeviceSystemInfo(si)
            m_rapi.GetDeviceVersion(vi)
            m_rapi.GetDeviceSystemPowerStatus(sps)
            m_rapi.GetDeviceMemoryStatus(ms)

            Select Case si.wProcessorArchitecture
                Case ProcessorArchitecture.Intel
                    info = "Intel Processor" & vbCrLf
                Case ProcessorArchitecture.MIPS
                    info = "MIPS Processor" & vbCrLf
                Case ProcessorArchitecture.ARM
                    info = "ARM Processor" & vbCrLf
                Case Else
                    info = "Unknown Processor" & vbCrLf
            End Select

            info = info & "CE Version: " & vi.dwMajorVersion & "." & vi.dwMinorVersion & "." & vi.dwBuildNumber & vbCrLf
            info = info & "AC Power: " & IIf(sps.ACLineStatus = 1, "ON", "OFF") & vbCrLf
            info = info & "Battery: " & sps.BatteryLifePercent & "%" & vbCrLf
            info = info & "Memory: " & String.Format("{0:###,###,###}", ms.dwTotalPhys) & vbCrLf


            txtInfo.Text = info

        Else
            m_rapi.Disconnect()
            txtInfo.Text = ""
            btnConnect.Text = "Connect"
        End If
    End Sub

    Private Sub m_activesync_Active() Handles m_activesync.Active
        lblStatus.Text = "Connected"
    End Sub

    Private Sub m_activesync_Listen() Handles m_activesync.Listen
        lblStatus.Text = "Not Connected"
    End Sub

    Private Sub m_activesync_Answer() Handles m_activesync.Answer
        lblStatus.Text = "Connecting"
    End Sub
End Class

⌨️ 快捷键说明

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