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

📄 frmmain.frm

📁 这个源代码主要模仿了一个类似 深度操作系统安装程序中的一个软件自动安装管理器AutoIt v3
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmMain 
   Caption         =   "软件自动安装管理器 Ver 1.0"
   ClientHeight    =   8325
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10350
   Icon            =   "frmMain.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   8325
   ScaleWidth      =   10350
   StartUpPosition =   1  '所有者中心
   Begin VB.Timer Timer1 
      Interval        =   300
      Left            =   195
      Top             =   7365
   End
   Begin VB.CommandButton Command1 
      Caption         =   "退出"
      Height          =   525
      Index           =   3
      Left            =   8805
      TabIndex        =   8
      Tag             =   "退出程序"
      Top             =   7365
      Width           =   1245
   End
   Begin VB.CommandButton Command1 
      Caption         =   "自动安装"
      Height          =   525
      Index           =   2
      Left            =   7275
      TabIndex        =   7
      Tag             =   "自动安装被选中的软件"
      Top             =   7350
      Width           =   1245
   End
   Begin VB.CommandButton Command1 
      Caption         =   "全选/取消"
      Height          =   525
      Index           =   1
      Left            =   5685
      TabIndex        =   6
      Tag             =   "全部选中和取消选中"
      Top             =   7350
      Width           =   1245
   End
   Begin VB.CommandButton Command1 
      Caption         =   "关于"
      Height          =   525
      Index           =   0
      Left            =   4110
      TabIndex        =   5
      Tag             =   "关于我们的信息"
      Top             =   7350
      Width           =   1245
   End
   Begin MSComctlLib.StatusBar StatusBar 
      Align           =   2  'Align Bottom
      Height          =   330
      Left            =   0
      TabIndex        =   3
      Top             =   7995
      Width           =   10350
      _ExtentX        =   18256
      _ExtentY        =   582
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   3
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            AutoSize        =   1
            Object.Width           =   12594
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.ListView lvSoftList 
      Height          =   5505
      Left            =   60
      TabIndex        =   1
      Top             =   1320
      Width           =   10200
      _ExtentX        =   17992
      _ExtentY        =   9710
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      Checkboxes      =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   4
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "软件名称"
         Object.Width           =   5186
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "软件版本及介绍"
         Object.Width           =   8538
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "文件状态"
         Object.Width           =   2893
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   3
         Text            =   "文件大小"
         Object.Width           =   2540
      EndProperty
   End
   Begin VB.PictureBox Picture1 
      BackColor       =   &H80000005&
      Height          =   990
      Left            =   45
      Picture         =   "frmMain.frx":076A
      ScaleHeight     =   930
      ScaleWidth      =   10245
      TabIndex        =   0
      Top             =   30
      Width           =   10305
   End
   Begin VB.Label Label2 
      BorderStyle     =   1  'Fixed Single
      Caption         =   "安装状态: "
      ForeColor       =   &H000080FF&
      Height          =   315
      Left            =   75
      TabIndex        =   4
      Top             =   6900
      Width           =   10020
   End
   Begin VB.Label Label1 
      Caption         =   "请选择要安装的软件:"
      Height          =   195
      Left            =   75
      TabIndex        =   2
      Top             =   1020
      Width           =   2460
   End
   Begin VB.Menu PopMenu 
      Caption         =   "界面显示"
      Visible         =   0   'False
      Begin VB.Menu mResto 
         Caption         =   "窗体还原"
         Shortcut        =   +^{F1}
      End
      Begin VB.Menu mSpace1 
         Caption         =   "-"
      End
      Begin VB.Menu mAbout 
         Caption         =   "关于(&A)"
      End
      Begin VB.Menu mExit 
         Caption         =   "退出(&Q)"
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Dim strFile As String
Dim isFinish As Boolean

Const PROCESS_ALL_ACCESS& = &H1F0FFF
Const STILL_ACTIVE& = &H103&
Const INFINITE& = &HFFFF

Private Declare Function ShellAbout Lib "shell32.dll" Alias _
  "ShellAboutA" (ByVal hWnd As Long, ByVal szApp As String, _
  ByVal szOtherStuff As String, ByVal hIcon As Long) As Long

Private Declare Function GetWindowsDirectory _
    Lib "kernel32" _
    Alias "GetWindowsDirectoryA" ( _
    ByVal lpBuffer As String, _
    ByVal nSize As Long _
    ) As Long


Private Declare Function OpenProcess _
    Lib "kernel32" ( _
    ByVal dwDesiredAccess As Long, _
    ByVal bInheritHandle As Long, _
    ByVal dwProcessID As Long _
    ) As Long


Private Declare Function WaitForSingleObject _
    Lib "kernel32" ( _
    ByVal hHandle As Long, _
    ByVal dwMilliseconds As Long _
    ) As Long


Private Declare Function GetExitCodeProcess _
    Lib "kernel32" ( _
    ByVal hProcess As Long, _
    lpExitCode As Long _
    ) As Long


Private Declare Function CloseHandle _
    Lib "kernel32" ( _
    ByVal hObject As Long _
    ) As Long

Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002


Private Sub Form_Load()

    Dim i As Integer
    Dim j As Integer
    Dim strSections() As String
    Dim strKeys() As String

    strFile = App.Path & "\Autoss.ini"
    strSections = ReadSections(strFile)
    j = 1
    For i = 0 To UBound(strSections)

        If strSections(i) <> "slist" And strSections(i) <> "config" And strSections(i) <> "" Then

            Call ReadKeys(strSections(i), strFile, strKeys)

            lvSoftList.ListItems.Add , , strSections(i)

            lvSoftList.ListItems(j).SubItems(1) = Replace$(strKeys(0), "info=", "")

            If FileExists(App.Path & "\" & Replace$(strKeys(1), "path=", "")) Then
                lvSoftList.ListItems(j).SubItems(2) = "准备就绪"
                lvSoftList.ListItems(j).Checked = True
                lvSoftList.ListItems(j).SubItems(3) = GetFileSize(App.Path & "\" & Replace$(strKeys(1), "path=", ""), ISPN_FT_SIZEINMB)
            Else
                lvSoftList.ListItems(j).SubItems(2) = "指定的文件不存在"
            End If
            j = j + 1
        End If
    Next

    StatusBar.Panels(2).Text = Format$(Date, "yyyy年mm月dd日")
    Call SystrayOn(Me, "剩余电流统计检测仪数据分析系统 Ver 1.20!" + vbCrLf + "双击图标还原")

    If Command$() = "/auto" Then '自动运行
        
        'frmCountdown
        Call Command1_Click(2)
    End If

    If Command$() = "/uninstall" Then  '执行卸载

       Call PopupBalloon(Me, "正在卸载软件,请稍后!", "提示", 1)
        
        strComputer = "."
        
        Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
            strComputer & "\root\default:StdRegProv")
        
        
        strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinRAR archiver"
        strValueName = "UninstallString"
        oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
        
        MyCheck = IsNull(strValue)
        
        If MyCheck = 0 Then
            Dim WshShell, oExec
            Set WshShell = CreateObject("WScript.Shell")
            
            strValue = Chr(34) & strValue & Chr(34)
            strValue = strValue & " /s"
            WshShell.Run strValue
        End If
       
       Call PopupBalloon(Me, "软件卸载完毕!", "提示", 1)
    End If

End Sub


Private Sub Command1_Click(Index As Integer)
    Dim i As Integer
    Dim sRunSoft As String
    Dim clsStartTerm As New clsStartTerminateProgram

    Select Case Index
        Case 0
        ShellAbout Me.hWnd, "软件自动安装管理器" & "#" & _
                   "欢迎使用软件自动安装管理器", _
                   "希望本软件能给您带来愉快的软件安装旅程...", Me.Icon    '    ByVal 0&

        Case 1  '全选、撤销
        For i = 1 To lvSoftList.ListItems.Count
            If lvSoftList.ListItems(i).SubItems(2) = "准备就绪" Then
                lvSoftList.ListItems(i).Checked = Not lvSoftList.ListItems(i).Checked
            End If
        Next

        Case 2
        For i = 1 To lvSoftList.ListItems.Count
            isFinish = True
            If lvSoftList.ListItems(i).Checked Then
                sRunSoft = ""
                sRunSoft = LPSTRToVBString$(INIRead(lvSoftList.ListItems.Item(i).Text, "path", strFile, "-1"))
                sRunSoft = App.Path & "\" & sRunSoft & " " & LPSTRToVBString$(INIRead(lvSoftList.ListItems.Item(i).Text, "run", strFile, "-1"))

                Label2.Caption = "正在安装" & lvSoftList.ListItems(i).Text & "...."
                Call PopupBalloon(Me, "正在安装" & lvSoftList.ListItems(i).Text & "...." & ",请稍后!", "安装提示", 1)

                clsStartTerm.StartProgram sRunSoft

                clsStartTerm.WaitForProgramToEnd

                Label2.Caption = "恭喜!" & lvSoftList.ListItems(i).Text & "安装完毕!"
                Call PopupBalloon(Me, "恭喜!" & lvSoftList.ListItems(i).Text & "安装完毕!", "安装提示", 1)
                If Command$() = "/auto" Then Unload Me
            End If
        Next
        Case 3
        Unload Me
    End Select
End Sub

Private Sub Command1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
   StatusBar.Panels(1).Text = Command1(Index).Tag
End Sub


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Static lngMsg            As Long
    Dim blnflag              As Boolean

    lngMsg = X / Screen.TwipsPerPixelX

    If blnflag = False Then
        blnflag = True
        Select Case lngMsg
            Case WM_RBUTTONCLK      '右键单击弹出菜单

            Call SetForegroundWindow(Me.hWnd)
            Call RemoveBalloon(Me)

            '定义右键弹出菜单
            PopupMenu PopMenu

            Case WM_LBUTTONDBLCLK   '右键双击显示窗口

            Call ChangeSystrayToolTip(Me, Me.Caption)
            Call SetForegroundWindow(Me.hWnd)
            Call RemoveBalloon(Me)
            Me.WindowState = vbNormal
            Me.Show
            Me.SetFocus

        End Select

        blnflag = False
    End If

End Sub

Private Sub Form_Resize()
    On Error Resume Next
    If Me.WindowState = vbMinimized Then
        Call SystrayOn(Me, "软件自动安装管理器 Ver 1.20!" + vbCrLf + "双击图标还原")
        Call ChangeSystrayToolTip(Me, "软件自动安装管理器 Ver 1.20!" + vbCrLf + "双击图标还原")
        Call PopupBalloon(Me, "软件自动安装管理器 Ver 1.20!" + vbCrLf + "双击图标还原", "提示", 1)
        ' Me.Hide
    End If

    If WindowState <> vbMinimized Then LastState = WindowState

    On Error GoTo 0

End Sub

Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    Dim Rate As Integer
    Dim Rate2 As Integer
    If WindowState <> 0 Then Exit Sub 'Windowstate = 0
    GotoVal = (Height / 12)
    Rate = 50 'Initial value

    For Gointo = 1 To GotoVal
        Spd = Timer
        Rate2 = Rate / 2
        Height = Height - Rate
        Top = Top + Rate2 '(Screen.Height - Height) \ 2

        DoEvents
        Width = Width - Rate
        Left = Left + Rate2 '(Screen.Width - Width) \ 2

        DoEvents
        If Width <= 2000 Then Exit For
        Rate = (Timer - Spd) * 10000
    Next Gointo
    WindowState = 1 'Minimize before disappearing

    '移除托盘
    Call SystrayOff(Me)

    End
End Sub

'调用 About
Private Sub mAbout_Click()
   Call Command1_Click(0)
End Sub

'还原界面
Private Sub mResto_Click()
   Me.WindowState = vbNormal
End Sub

'时钟
Private Sub Timer1_Timer()
   StatusBar.Panels(3).Text = Time
End Sub

⌨️ 快捷键说明

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