宝峰科技

 找回密码
 注册

QQ登录

只需一步,快速开始

智能终端设备维修查询系统注册会员邮箱认证须知!
查看: 3856|回复: 1

[VB例程源码] 强制结束进程源码

  [复制链接]

该用户从未签到

mythhack 发表于 2010-10-13 20:07:43 | 显示全部楼层 |阅读模式

欢迎您注册加入!这里有您将更精采!

您需要 登录 才可以下载或查看,没有账号?注册

x
这几天闲来无事玩了玩DNF 退出游戏的时候觉得N慢 想了想直接结束进程是最快的所以突发奇想写出的  请各位大虾们指点
Form1:
--------------------------------------------------调用方法---------------------------------------------------

  1. Private Sub Command1_Click()
  2. TerminateFileName "你要结束的进程名字"
  3. End Sub
  4. 例如:
  5. Private Sub Command1_Click()
  6. TerminateFileName "QQLogin.exe"
  7. End Sub
复制代码
模块:
--------------------------------------------------Module1.bas------------------------------------------------

  1. Option Explicit
  2. Public Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
  3. Public Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
  4. Public Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
  5. Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  6. Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  7. Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  8. Public Const TH32CS_SNAPPROCESS = &H2
  9. Public Const TH32CS_SNAPheaplist = &H1
  10. Public Const TH32CS_SNAPthread = &H4
  11. Public Const TH32CS_SNAPmodule = &H8
  12. Public Const TH32CS_SNAPall = TH32CS_SNAPPROCESS + TH32CS_SNAPheaplist + TH32CS_SNAPthread + TH32CS_SNAPmodule
  13. Public Const MAX_PATH As Integer = 260
  14. Public Const PROCESS_TERMINATE = &H1
  15. Public Type PROCESSENTRY32
  16.     dwSize As Long
  17.     cntUsage As Long
  18.     th32ProcessID As Long
  19.     th32DefaultHeapID As Long
  20.     th32ModuleID As Long
  21.     cntThreads As Long
  22.     th32ParentProcessID As Long
  23.     pcPriClassBase As Long
  24.     dwFlags As Long
  25.     szExeFile As String * MAX_PATH
  26. End Type
  27. Public Sub TerminateFileName(FileName As String)
  28.     Dim proc As PROCESSENTRY32
  29.     Dim snap As Long
  30.     Dim exename As String
  31. Dim theloop As Long
  32.     Dim hand As Long
  33.     Dim FileID As Long
  34.     snap = CreateToolhelpSnapshot(TH32CS_SNAPall, 0)
  35.     proc.dwSize = Len(proc)
  36.     theloop = ProcessFirst(snap, proc)
  37.     While theloop <> 0
  38.         exename = proc.szExeFile
  39.         If Left(Trim(LCase(exename)), Len(FileName)) = LCase(FileName) Then
  40.             FileID = proc.th32ProcessID
  41.             hand = OpenProcess(PROCESS_TERMINATE, True, FileID)
  42.             TerminateProcess hand, 0
  43.             CloseHandle snap
  44.             Exit Sub
  45.         End If
  46.         theloop = ProcessNext(snap, proc)
  47.     Wend
  48. CloseHandle snap
  49. End Sub
复制代码
请大家不要见笑啊···· By:Mythhack
  • TA的每日心情
    开心
    2012-7-29 00:25
  • 签到天数: 6 天

    [LV.2]偶尔看看I

    花心胡萝卜 发表于 2010-11-22 11:34:46 | 显示全部楼层
    用了API哦,不错,支持一下!
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    免责声明

    本站中所有被研究的素材与信息全部来源于互联网,版权争议与本站无关。本站所发布的任何软件编程开发或软件的逆向分析文章、逆向分析视频、补丁、注册机和注册信息,仅限用于学习和研究软件安全的目的。全体用户必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。学习编程开发技术或逆向分析技术是为了更好的完善软件可能存在的不安全因素,提升软件安全意识。所以您如果喜欢某程序,请购买注册正版软件,获得正版优质服务!不得将上述内容私自传播、销售或者用于商业用途!否则,一切后果请用户自负!

    QQ|Archiver|手机版|小黑屋|联系我们|宝峰科技 ( 滇公网安备 53050202000040号 | 滇ICP备09007156号-2 )

    Copyright © 2001-2023 Discuz! Team. GMT+8, 2024-12-22 12:50 , File On Powered by Discuz! X3.49

    快速回复 返回顶部 返回列表