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

📄 form1.vb

📁 基于wince 4.2 .net 平台 CF1.0 SDK 做为GPS上的一个外壳程序.程序比较简单.但是却非常的实用.很多wince的开发人员都在找如相操作打开另外一个程序的办法.看看这个吧.
💻 VB
字号:
Imports System.Runtime.InteropServices

Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub
    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        MyBase.Dispose(disposing)
    End Sub

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents LB1 As System.Windows.Forms.Label
    Friend WithEvents BT1 As System.Windows.Forms.Button
    Friend WithEvents BT2 As System.Windows.Forms.Button
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents BT3 As System.Windows.Forms.Button
    Friend WithEvents BT4 As System.Windows.Forms.Button
    Private Sub InitializeComponent()
        Me.BT1 = New System.Windows.Forms.Button
        Me.BT2 = New System.Windows.Forms.Button
        Me.LB1 = New System.Windows.Forms.Label
        Me.Button1 = New System.Windows.Forms.Button
        Me.BT3 = New System.Windows.Forms.Button
        Me.BT4 = New System.Windows.Forms.Button
        '
        'BT1
        '
        Me.BT1.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular)
        Me.BT1.Location = New System.Drawing.Point(40, 24)
        Me.BT1.Size = New System.Drawing.Size(104, 64)
        Me.BT1.Text = "napp1"
        '
        'BT2
        '
        Me.BT2.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular)
        Me.BT2.Location = New System.Drawing.Point(176, 24)
        Me.BT2.Size = New System.Drawing.Size(104, 64)
        Me.BT2.Text = "napp2"
        '
        'LB1
        '
        Me.LB1.ForeColor = System.Drawing.Color.DarkRed
        Me.LB1.Location = New System.Drawing.Point(8, 187)
        Me.LB1.Size = New System.Drawing.Size(296, 16)
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(40, 96)
        Me.Button1.Size = New System.Drawing.Size(0, 0)
        Me.Button1.Text = "Button1"
        '
        'BT3
        '
        Me.BT3.Location = New System.Drawing.Point(40, 112)
        Me.BT3.Size = New System.Drawing.Size(104, 64)
        Me.BT3.Text = "napp3"
        '
        'BT4
        '
        Me.BT4.Location = New System.Drawing.Point(176, 112)
        Me.BT4.Size = New System.Drawing.Size(104, 64)
        Me.BT4.Text = "napp4"
        '
        'Form1
        '
        Me.ClientSize = New System.Drawing.Size(316, 215)
        Me.Controls.Add(Me.BT4)
        Me.Controls.Add(Me.BT3)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.BT2)
        Me.Controls.Add(Me.BT1)
        Me.Controls.Add(Me.LB1)
        Me.Text = "双导航软件切换工具"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized

    End Sub

#End Region
    Dim napp1, napp2, papp1, papp2 As String
    Dim napp3, napp4, papp3, papp4 As String
    Dim selfPath As String
    Public Function readtext(ByVal path As String)
        If path = "" Then
            readtext = "操作失败!"
            Exit Function
        End If
        Try
            If System.IO.File.Exists(path) = True Then
                Dim fs As New System.IO.FileStream(path, System.IO.FileMode.Open)
                Dim sr As New System.IO.StreamReader(fs, System.Text.Encoding.Default)
                Dim str As String
                str = sr.ReadToEnd.ToString
                sr.Close()
                fs.Close()
                readtext = str
            Else
                readtext = "操作失败!"
            End If
        Catch ex As Exception
            readtext = "操作失败!"
        End Try
    End Function
    Public Sub OpenExe(ByVal fs As String)
        Dim tudtShellExecuteInfo As New myfun.SHELLEXECUTEINFO
        Dim tstrExecutePath As String
        Dim tudtStartupInfo As myfun.STARTUPINFO
        'Dim tudtProcessInfo As myfun.PROCESS_INFORMATION
        Dim tlngTempa As Int32
        If System.IO.File.Exists(fs) Then
            With tudtStartupInfo
                .cb = Marshal.SizeOf(GetType(myfun.STARTUPINFO))
            End With
            With tudtShellExecuteInfo
                .cbSize = Marshal.SizeOf(GetType(myfun.SHELLEXECUTEINFO))
                .lpFile = clsDAMSMobileMarshal.fnStringToHLocalUni(fs) '设定文件
                .lpParameters = IntPtr.Zero '不使用参数,如使用参数可按lpFile的方法申请字符串指针 
            End With
            tlngTempa = myfun.ShellExecuteEx(tudtShellExecuteInfo) '启动程序 
            tudtShellExecuteInfo.Dispose()
            LB1.Text = ""
        Else
            LB1.Text = "警告:" + fs + " [找不到!]"
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Const mps = "\sdmmc\app\"
        selfPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase) + "\"
        napp1 = readtext(selfPath + "napp1.ini")
        papp1 = readtext(selfPath + "papp1.ini")
        BT1.Text = napp1
        '-----------------------------
        napp2 = readtext(selfPath + "napp2.ini")
        papp2 = readtext(selfPath + "papp2.ini")
        BT2.Text = napp2

        napp3 = readtext(selfPath + "napp3.ini")
        papp3 = readtext(selfPath + "papp3.ini")
        BT3.Text = napp3

        napp4 = readtext(selfPath + "napp4.ini")
        papp4 = readtext(selfPath + "papp4.ini")
        BT4.Text = napp4
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT1.Click
        ' Dim fs As String
        '城际通
        OpenExe(papp1)
        'OpenExe("\sdmmc\Navi\Navi.exe")
        'OpenExe("\sdmmc\CJT\cjmap.exe")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT2.Click
        ' Dim fs As String
        '凯瑞德
        OpenExe(papp2)
        ' OpenExe("\sdmmc\Navione\Navione.exe")
    End Sub

    Private Sub StatusBar1_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub BT3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT3.Click
        OpenExe(papp3)
    End Sub

    Private Sub BT4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT4.Click
        OpenExe(papp4)
    End Sub
End Class

⌨️ 快捷键说明

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