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

📄 增强任务管理器.frm

📁 个人VB学习源码精选,自己学习时的一些编程小程序,希望对大家有帮助
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "任务管理器"
   ClientHeight    =   3330
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5205
   LinkTopic       =   "Form1"
   ScaleHeight     =   3330
   ScaleWidth      =   5205
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "退出(&Q)"
      Height          =   315
      Left            =   2835
      TabIndex        =   3
      Top             =   2880
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "结束任务(&E)"
      Height          =   315
      Left            =   1155
      TabIndex        =   2
      Top             =   2880
      Width           =   1215
   End
   Begin VB.ListBox List1 
      Height          =   2040
      Left            =   165
      TabIndex        =   0
      Top             =   120
      Width           =   4875
   End
   Begin VB.Label Label1 
      Caption         =   "警告:“结束任务”有可能导致系统崩溃,在结束之前请确信程式序用途。"
      Height          =   375
      Left            =   165
      TabIndex        =   1
      Top             =   2280
      Width           =   4875
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
Private Const WM_CLOSE = &H10
Private Const GW_HWNDFIRST = 0
Private Const GW_HWNDNEXT = 2
Private WindowsText As String * 256
Private Programs(200) As Long
Private Sub RunningProgram()
    Dim GetWinValue As Long, ProgramNums As Long
    Dim GetWinTextValue As Long, WindowsTextLength As Long
    
    ProgramNums = 0
    List1.Clear
    GetWinValue = GetWindow(Form1.hwnd, GW_HWNDFIRST)
    Do
        GetWinTextValue = GetWindowText(GetWinValue, WindowsText, 256)
        If GetWinTextValue <> 0 Then
            WindowsTextLength = GetWindowTextLength(GetWinValue)
            If Left(WindowsText, WindowsTextLength) <> Form1.Caption And Left(WindowsText, WindowsTextLength) <> App.Title Then
                Form1.List1.AddItem WindowsText
                Programs(ProgramNums) = GetWinValue
                ProgramNums = ProgramNums + 1
            End If
        End If
        GetWinValue = GetWindow(GetWinValue, GW_HWNDNEXT)
    Loop Until GetWinValue = 0
End Sub

Private Sub Command1_Click()
    Dim GetWinTextValue As Long
    If MsgBox("确实要关闭" & "“" & List1.List(List1.ListIndex) & "”", vbYesNo + vbQuestion, "确认框") = vbYes Then
        GetWinTextValue = SendMessage(Programs(List1.ListIndex), WM_CLOSE, 0, 0)
        If GetWinTextValue <> 0 Then
            MsgBox "对不起,当前程序不能关闭!", vbCritical, "不成功"
            Call RunningProgram
        Else
            MsgBox "程序已经关闭!", vbInformation, "成功"
            Call RunningProgram
        End If
    End If
End Sub

Private Sub Command2_Click()
    End
End Sub

Private Sub Form_Load()
    SetWindowPos Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE
    Call RunningProgram
    Form1.Icon = LoadPicture()
End Sub


⌨️ 快捷键说明

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