vb怎么禁用任务管理器

vb怎么禁用任务管理器,第1张

Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Const MAX_PATH As Long = 260
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String MAX_PATH
End Type
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode 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 CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const TH32CS_SNAPPROCESS = &H2
Private Const TH32CS_SNAPheaplist = &H1
Private Const TH32CS_SNAPthread = &H4
Private Const TH32CS_SNAPmodule = &H8
Private Const TH32CS_SNAPall = TH32CS_SNAPPROCESS + TH32CS_SNAPheaplist + TH32CS_SNAPthread + TH32CS_SNAPmodule
Private Const PROCESS_TERMINATE As Long = (&H1)
Private Sub Timer1_Timer()
Dim i As Long
Dim proc As PROCESSENTRY32
Dim snap As Long
Dim exename As String
Dim theloop As Long
Dim hand As Long
snap = CreateToolhelpSnapshot(TH32CS_SNAPall, 0) '获得进程“快照”的句柄
procdwSize = Len(proc)
theloop = ProcessFirst(snap, proc) '获取第一个进程,并得到其返回值
While theloop <> 0 '当返回值非零时继续获取下一个进程
exename = procszExeFile
If InStr(UCase(exename), "TASKMGREXE") <> 0 Then '将进程名全部转换成大写
hand = OpenProcess(PROCESS_TERMINATE, True, procth32ProcessID)
TerminateProcess hand, 0
End If
theloop = ProcessNext(snap, proc)
Wend
End Sub
设置好TIMER1的时间就可以了,可以结束任务管理器进程
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Dim task As Long
Dim win As Long
Dim bswap As Boolean

Private Sub Command1_Click()
If Not bswap Then
SetParent win, Mehwnd
ShowWindow win, 0
Else
SetParent win, task
ShowWindow win, 1
End If
bswap = Not bswap
End Sub

Private Sub Form_Load()
task = FindWindow("Shell_TrayWnd", vbNullString)
If task Then
win = FindWindowEx(task, 0, "Button", vbNullString)
If win Then
Else
MsgBox "没有找到开始按钮"
Unload Me
End If
Else
MsgBox "没有找到任务栏"
Unload Me
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
If bswap Then
SetParent win, task
ShowWindow win, 1
End If
End Sub
这段可以禁止开始,在程序退出后,恢复开始

Frame 控件 Frame 控件为控件提供可标识的分组。Frame 可以在功能上进一步分割一个窗体-例如,把 OptionButton 控件分成几组。语法Frame说明为了将控件分组,首先需要绘制 Frame 控件,然后绘制 Frame 里面的控件。这样就可以把框架和里面的控件同时移动。如果在 Frame 外部绘制了一个控件并试图把它移到框架内部,那么控件将在 Frame 的上部,这时需分别移动 Frame 和控件。为了在 Frame 中选择多个控件,在使用鼠标在控件周围绘制框时,按住 CTRL 键。


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

原文地址: http://outofmemory.cn/yw/12968044.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-29
下一篇 2023-05-29

发表评论

登录后才能评论

评论列表(0条)

保存