VB 挂起和恢复进程

VB 挂起和恢复进程,第1张

概述VERSION 5.00 Begin VB.Form frmMain    Caption         =   "Form1"    ClientHeight    =   3090    ClientLeft      =   60    ClientTop       =   450    ClientWidth     =   4680    LinkTopic       =   "F

VERSION 5.00
Begin VB.Form frmMain
Caption = "Form1"
ClIEntHeight = 3090
ClIEntleft = 60
ClIEnttop = 450
ClIEntWIDth = 4680
linktopic = "Form1"
ScaleHeight = 3090
ScaleWIDth = 4680
StartUpposition = 3 '窗口缺省
Begin VB.Commandbutton cmdTerminate
Caption = "终止该进程"
Height = 375
left = 3240
TabIndex = 3
top = 1920
WIDth = 1335
End
Begin VB.Commandbutton cmdClose
Caption = "关闭句柄"
Height = 495
left = 1920
TabIndex = 2
top = 1800
WIDth = 1335
End
Begin VB.TextBox txtPID
Height = 495
left = 720
TabIndex = 1
Text = "123"
top = 480
WIDth = 1695
End
Begin VB.Commandbutton cmdResume
Caption = "恢复进程"
Height = 495
left = 120
TabIndex = 0
top = 1800
WIDth = 1815
End
End
Attribute VB_name = "frmMain"
Attribute VB_GlobalnameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredID = True
Attribute VB_Exposed = False
Private Declare Function OpenProcess lib "kernel32" (ByVal DWDesiredAccess As Long,ByVal binheritHandle As Long,ByVal DWProcessID As Long) As Long
Private Declare Function CloseHandle lib "kernel32" (ByVal hObject As Long) As Long
Private Const SYNCHRONIZE = &H100000
Private Const STANDARD_RIGHTS_required = &HF0000
Private Const PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_required Or SYNCHRONIZE Or &HFFF)
Private Declare Function NtSuspendProcess lib "ntdll.dll" (ByVal hProc As Long) As Long
Private Declare Function NtResumeProcess lib "ntdll.dll" (ByVal hProc As Long) As Long
Private Declare Function TerminateProcess lib "kernel32" (ByVal hProcess As Long,ByVal uExitCode As Long) As Long
Private hProcess As Long

Private Sub cmdClose_Click()
CloseHandle hProcess
End Sub

Private Sub cmdResume_Click()
If IsNumeric(txtPID.Text) Then
hProcess = OpenProcess(PROCESS_ALL_ACCESS,False,CLng(txtPID.Text))
If hProcess <> 0 Then
NtResumeProcess hProcess
End If
End If
End Sub

Private Sub cmdTerminate_Click() If hProcess Then TerminateProcess hProcess,0 Else If IsNumeric(txtPID.Text) Then hProcess = OpenProcess(PROCESS_ALL_ACCESS,CLng(txtPID.Text)) If hProcess <> 0 Then TerminateProcess hProcess,0 End If End If End IfEnd Sub

总结

以上是内存溢出为你收集整理的VB 挂起和恢复进程全部内容,希望文章能够帮你解决VB 挂起和恢复进程所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1292669.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-10
下一篇2022-06-10

发表评论

登录后才能评论

评论列表(0条)

    保存