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

📄 停止指定程序运行.frm

📁 Windows API函数,希望大伙有用哦
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BackColor       =   &H80000013&
   Caption         =   "Form1"
   ClientHeight    =   1650
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   1650
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text1 
      Alignment       =   1  'Right Justify
      Height          =   315
      Left            =   1890
      TabIndex        =   0
      Top             =   450
      Width           =   1905
   End
   Begin VB.CommandButton Command1 
      Caption         =   "关   闭"
      Enabled         =   0   'False
      Height          =   345
      Left            =   2940
      TabIndex        =   1
      Top             =   1050
      Width           =   1305
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "请输入程序名称:"
      Height          =   180
      Left            =   210
      TabIndex        =   2
      Top             =   510
      Width           =   1440
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CLOSE = &H10
Dim Ret As String
Private Sub Text1_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
   Ret = Text1
   Command1.Enabled = True
   Command1.SetFocus
  End If
End Sub
Private Sub Command1_Click()
  Dim WinWnd As Long
  WinWnd = FindWindow(vbNullString, Ret)
  If Text1 = "" Then
       MsgBox "  没有选择运行程序 !  "
       Else
    If WinWnd <> 0 Then
     PostMessage WinWnd, WM_CLOSE, &O0, &O0
       MsgBox "  " & Ret & " 已经停止运行 !  "
     Else
       MsgBox "  " & Ret & " 没有运行 !  "
    End If
 End If
End Sub

⌨️ 快捷键说明

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