VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 从任务列表中隐藏 按Ctrl+Alt+Del时也不会显示出来
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:7487, 日期:2004-10-28
程序说明:

  这个程序比较简单,只使用了GetCurrentProcessId 和 RegisterServiceProcess 两个函数就可以达到。

  这种方法只能在 Windows98 中运行,在 Windows2000中是不行的

  程序代码:

Module1

Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0

下面代码为隐藏

Public Sub MakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId() 注释:取的当前运行的程序Id

regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
对当前的程序传入 RSP_SIMPLE_SERVICE 消息,使此程序
从任务列表中隐藏
End Sub

注释:恢复隐藏
Public Sub UnMakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE)
原理同上
End Sub

Private Sub Command1_Click()
Call MakeMeService
End Sub

Private Sub Command2_Click()
Call UnMakeMeService
End Sub

Private Sub Form_Load()
Form1.Left = Screen.Width / 2 - Form1.Width / 2
Form1.Top = Screen.Height / 2 - Form1.Height / 2
End Sub