| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 765 人关注过本帖
标题:小菜也能屏蔽任务管理器拉(简单实用)
只看楼主 加入收藏
VB狂热菜鸟
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2007-3-7
收藏
 问题点数:0 回复次数:5 
小菜也能屏蔽任务管理器拉(简单实用)

原理很简单,用FINDWINDOW函数寻找 任务管理器,如果监测到其运行,则显示一个最大化的窗口,并且将其窗口设置为始终在最前端。
建议大家先把窗口的属性设置为无边框和最大化。 我试过,还真不能用任务管理器关闭这个程序了。

特此感谢帮助我门这些小菜的人!!!

Option Explicit

Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) 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 Sub cmdAllTop()
Dim rectTemp As RECT
GetWindowRect Form1.hwnd, rectTemp
SetWindowPos Form1.hwnd, HWND_TOPMOST, _
rectTemp.Left, rectTemp.Top, rectTemp.Right - rectTemp.Left, rectTemp.Bottom - rectTemp.Top, 0
End Sub

'Ñ°ÕÒ´°¿ÚÁбíÖеÚÒ»¸ö·ûºÏÖ¸¶¨Ìõ¼þµÄ¶¥¼¶´°¿ÚµÄAPIµ÷ÓÃ
'ÔÚ´°¿ÚÖн¨Á¢Ò»timer¿Ø¼þºÍLabel1¿Ø¼þ,È»ºóÔÚ´úÂë´°¿ÚÊäÈëÈçÏ´úÂë:
Private Sub Form_Load()
Form1.Visible = False
Timer1.Interval = 500
End Sub

Private Sub Label1_Click()
End
End Sub

'timer¿Ø¼þºÍLabel1¿Ø¼þµÄ´úÂëÈçÏÂ:
Private Sub Timer1_Timer()
Dim hwnd As Long
hwnd = FindWindow(vbNullString, "Windows ÈÎÎñ¹ÜÀíÆ÷") 'ץȡ"ÄãÐèÒªµÄ³ÌÐòÃû"µÄ´°¿ÚÃû³Æ.
If (hwnd = 0) Then
Label1.Caption = "³ÌÐòδ¼ÓÔØ"
ElseIf (hwnd <> 0) Then
Label1.Caption = "³ÌÐòÒѼÓÔØ"
Call cmdAllTop
Form1.Visible = True
End If
End Sub

搜索更多相关主题的帖子: 管理器 小菜 任务 
2007-03-23 12:14
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 

怎么这么多乱码?


我的msn: myfend@
2007-03-23 12:16
VB狂热菜鸟
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2007-3-7
收藏
得分:0 

对不起,乱码是复制过来的汉字无法显示出来。我整理了一下,现在好了。


Option Explicit

Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) 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 Sub cmdAllTop()
Dim rectTemp As RECT
GetWindowRect Form1.hwnd, rectTemp
SetWindowPos Form1.hwnd, HWND_TOPMOST, _
rectTemp.Left, rectTemp.Top, rectTemp.Right - rectTemp.Left, rectTemp.Bottom - rectTemp.Top, 0
End Sub


Private Sub Form_Load()
Form1.Visible = False
Timer1.Interval = 500
End Sub

Private Sub Label1_Click()
End
End Sub


Private Sub Timer1_Timer()
Dim hwnd As Long
hwnd = FindWindow(vbNullString, "Windows 任务管理器")
If (hwnd = 0) Then
Label1.Caption = "程序未加载"
ElseIf (hwnd <> 0) Then
Label1.Caption = "程序已加载"
Call cmdAllTop
Form1.Visible = True
End If
End Sub

2007-03-23 12:43
wenber0598
Rank: 1
等 级:新手上路
帖 子:101
专家分:0
注 册:2007-2-27
收藏
得分:0 
顶!

三人行必有我师
2007-03-23 14:52
VB狂热菜鸟
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2007-3-7
收藏
得分:0 
感谢上楼!   不过没多少人评价呢?大家看贴也给个意见撒
2007-03-23 18:40
121038
Rank: 1
等 级:新手上路
威 望:2
帖 子:414
专家分:0
注 册:2005-8-3
收藏
得分:0 

支持一下但不够简单
看我的,一行代码彻底屏蔽
http://bbs.bc-cn.net/viewthread.php?tid=121793


2007-03-23 21:27
快速回复:小菜也能屏蔽任务管理器拉(简单实用)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016395 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved