请问vb怎样看隐藏进程?

luoweihao 2006-06-13 12:56:05
可以吗?我是一只菜鸟
...全文
1372 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
清晨曦月 2006-06-16
  • 打赏
  • 举报
回复
。。。。。。。。。。。纳闷中,这是夸谁还是骂谁啊,嘎嘎。。。。
代码里面的CMD1、CMD2没什么用的,原来我是用来停止和启动服务的,楼主不需要就给删 了
c51301607 2006-06-16
  • 打赏
  • 举报
回复
非常的感谢这位楼兄,查资料都查了好久,
清晨曦月 2006-06-15
  • 打赏
  • 举报
回复
楼主赏分啊,我这么少。。。。。。给加点我好去问问题麻!
清晨曦月 2006-06-14
  • 打赏
  • 举报
回复
不客气不客气,
luoweihao 2006-06-13
  • 打赏
  • 举报
回复
谢谢!
kmlxk0 2006-06-13
  • 打赏
  • 举报
回复
清晨曦月 2006-06-13
  • 打赏
  • 举报
回复
呵呵,这代码还得感谢楼上的老兄啊,我是最近新学的,嘎嘎,还是经过你的提示。。。

verywzm 2006-06-13
  • 打赏
  • 举报
回复
UP
清晨曦月 2006-06-13
  • 打赏
  • 举报
回复
恩,难。。。。隐藏进程,在9X和2K中是不大一样的,例如说你想隐藏一个进程,在9X里面一个API就可以了,可是2K以上系统就不行了。。。2K里面隐藏进程一般都是系统服务,所以不会显示,大家多利用这个特性来弄,也许有写VXD的,不过VB里面想实现一般是写成服务了,写服务比较普遍,那么你取得服务就可以了。。给出最近完成的一个WINDOWS服务管理器的部分代码。该代码在WINXP,VB6+SP6,WMI1.2(XP自带)测试通过。
测试代码前请添加对MS WMI 1.X的引用,添加一个LISTVIEW(MS CMD CON 6.0里面的),名称默认,一个TEXTBOX,名称为TxtDescription
具体代码如下:

Option Explicit

Dim objSWbemLocator As SWbemLocator
Dim objSWbemServices As SWbemServices
Dim objSWbemObjectSet As SWbemObjectSet
Dim objSWbemObject As SWbemObject
Dim strComputer As String, strNameSpace As String, strClass As String


Private Sub Form_Load()
ListView1.ColumnHeaders.Clear
ListView1.ColumnHeaders.Add , , "名称", 2600
ListView1.ColumnHeaders.Add , , "状态", 1000
ListView1.ColumnHeaders.Add , , "启动类型", 1000
ListView1.ColumnHeaders.Add , , "路径", 2600
ListView1.ColumnHeaders.Add , , "登录身份", 1400
ListView1.ColumnHeaders.Add , , "进程ID", 900
ListView1.ColumnHeaders.Add , , "服务类型", 1400
ListView1.View = lvwReport
ListView1.FullRowSelect = True

strComputer = "." '计算机名,.为本机
strNameSpace = "root\cimv2" '指定命名空间为root\cimv2
strClass = "Win32_Service" '指定类为Win32_Service
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") '建立1个WBEM对象的引用指针
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, strNameSpace) '连接到指定计算机、命名空间的WMI,返回一个对 SWbemServices 对象的引用
RefreshList '刷新服务列表
End Sub
'刷新服务列表
Sub RefreshList()
Dim i As Long
ListView1.ListItems.Clear
Set objSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM " & strClass) '通过WQL查询,返回指定类的所有
For Each objSWbemObject In objSWbemObjectSet
ListView1.ListItems.Add , "a" & i, objSWbemObject.DisplayName '将服务名称添加到ListView1第一列
ListView1.ListItems("a" & i).SubItems(1) = objSWbemObject.State '将服务的状态添加到ListView1第二列
ListView1.ListItems("a" & i).SubItems(2) = objSWbemObject.StartMode '将服务的启动方式添加到ListView1第三列
ListView1.ListItems("a" & i).SubItems(3) = objSWbemObject.PathName '将服务程序的路径添加到ListView1第四列
ListView1.ListItems("a" & i).SubItems(4) = objSWbemObject.StartName '将服务的登录身份添加到ListView1第五列
ListView1.ListItems("a" & i).SubItems(5) = objSWbemObject.ProcessId '将服务的进程ID添加到ListView1第六列,这里就是你所需要的隐藏的进程的PID了
ListView1.ListItems("a" & i).SubItems(6) = objSWbemObject.ServiceType '将服务类型添加到ListView1第7列
If IsNull(objSWbemObject.Description) Then '添加说明
ListView1.ListItems("a" & i).Tag = "无"
Else
ListView1.ListItems("a" & i).Tag = objSWbemObject.Description
End If
i = i + 1
Next
Set ListView1.SelectedItem = ListView1.ListItems(1)
End Sub
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
If Item.SubItems(1) = "Stopped" Then
Command1.Enabled = False
Command2.Enabled = True
Else
Command1.Enabled = True
Command2.Enabled = False
End If

' Set objSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM " & strClass & " WHERE DisplayName = '" & ListView1.SelectedItem.Text & "'") '查询类中DisplayName属性等于指定值的实例
' For Each objSWbemObject In objSWbemObjectSet
' If IsNull(objSWbemObject.Description) Then '添加说明
' TxtDescription.Text = "无"
' Else
' TxtDescription.Text = objSWbemObject.Description
' End If
' Next
'将说明显示出来
TxtDescription.Text = ListView1.ListItems("a" & ListView1.SelectedItem.Index - 1).Tag
End Sub

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧