同情你!我已经声明了PROCESS32和module32 的结构但是这个东东不知怎么没反应,也不报错!
还缺什么东东!!!大家指点一下!!
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, lProcessID As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Function GetWindowThreadProcessId& Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long)
Private Declare Function Process32First Lib "kernel32" (ByVal hsnapshot As Long, uprocess As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hsnapshot As Long, uprocess As PROCESSENTRY32) As Long
Private Declare Function Module32First Lib "kernel32" (ByVal hsnapshot As Long, lppe As MODULEENTRY32) As Long
Private Declare Function Module32Next Lib "kernel32" (ByVal hsnapshot As Long, lppe As MODULEENTRY32) As Long
Private Type MODULEENTRY32
dwSize As Long
th32ModuleID As Long
th32ProcessID As Long
GlblcntUsage As Long
ProccntUsage As Long
modBaseAddr As Byte
modBaseSize As Long
hModule As Long
szModule As String * 256
szExePath As String * 1024
End TypePrivate 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 * 260&
End Type
Private Const TH32CS_SNAPPROCESS As Long = 2&
Private Const TH32CS_SNAPMODULE = &H8
Dim procresultPrivate Sub lvw_Click()
ProcH.StatusBar1.Panels(2).Text = lvw.SelectedItem
Modulelis
End Sub
Sub Modulelis()
clvw.ListItems.Clear ''''清空列表,初始化
clvw.ColumnHeaders.Clear ''''清空表头,初始化
clvw.ColumnHeaders.Add , , "模块名称", 2000 '''添加到表头第一项,有顺序的
clvw.ColumnHeaders.Add , , "模块路径", 4000
clvw.ColumnHeaders.Add , , "占用内存", 1000
clvw.ColumnHeaders.Add , , "引用", 600
clvw.ColumnHeaders.Add , , "全局引用", 1000
clvw.ColumnHeaders.Add , , "模块ID", 1000
clvw.LabelEdit = lvwManual
clvw.FullRowSelect = True
clvw.HideSelection = False
clvw.HideColumnHeaders = False
clvw.View = lvwReport
Dim uprocess As PROCESSENTRY32
Dim l As Long
Dim mm As MODULEENTRY32
Dim lm As Long
Dim modlvw As ListItem
l = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If l > 0 Then
uprocess.dwSize = Len(uprocess)
If Process32First(l, uprocess) Then
Do
'获得进程的标识符
lm = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, uprocess.th32ProcessID)
If lm > 0 Then
mm.dwSize = Len(mm)
If Module32First(lm, mm) Then
Do
If uprocess.th32ProcessID = mm.th32ProcessID Then
' Set modlvw = clvw.ListItems.Add(, , Text:=Str$(mm.szExePath))
'modlvw.SubItems(5) = mm.ProccntUsage
'modlvw.SubItems(4) = mm.szExePath
' modlvw.SubItems(3) = mm.hModule
' modlvw.SubItems(2) = mm.modBaseAddr
' modlvw.SubItems(1) = mm.modBaseSize
End If
Loop Until (Module32Next(lm, mm) < 1)
End If
CloseHandle (lm)
End If
Loop Until (Process32Next(l, uprocess) < 1)
End If
CloseHandle (l)
End If
End Sub
还缺什么东东!!!大家指点一下!!
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, lProcessID As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Function GetWindowThreadProcessId& Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long)
Private Declare Function Process32First Lib "kernel32" (ByVal hsnapshot As Long, uprocess As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hsnapshot As Long, uprocess As PROCESSENTRY32) As Long
Private Declare Function Module32First Lib "kernel32" (ByVal hsnapshot As Long, lppe As MODULEENTRY32) As Long
Private Declare Function Module32Next Lib "kernel32" (ByVal hsnapshot As Long, lppe As MODULEENTRY32) As Long
Private Type MODULEENTRY32
dwSize As Long
th32ModuleID As Long
th32ProcessID As Long
GlblcntUsage As Long
ProccntUsage As Long
modBaseAddr As Byte
modBaseSize As Long
hModule As Long
szModule As String * 256
szExePath As String * 1024
End TypePrivate 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 * 260&
End Type
Private Const TH32CS_SNAPPROCESS As Long = 2&
Private Const TH32CS_SNAPMODULE = &H8
Dim procresultPrivate Sub lvw_Click()
ProcH.StatusBar1.Panels(2).Text = lvw.SelectedItem
Modulelis
End Sub
Sub Modulelis()
clvw.ListItems.Clear ''''清空列表,初始化
clvw.ColumnHeaders.Clear ''''清空表头,初始化
clvw.ColumnHeaders.Add , , "模块名称", 2000 '''添加到表头第一项,有顺序的
clvw.ColumnHeaders.Add , , "模块路径", 4000
clvw.ColumnHeaders.Add , , "占用内存", 1000
clvw.ColumnHeaders.Add , , "引用", 600
clvw.ColumnHeaders.Add , , "全局引用", 1000
clvw.ColumnHeaders.Add , , "模块ID", 1000
clvw.LabelEdit = lvwManual
clvw.FullRowSelect = True
clvw.HideSelection = False
clvw.HideColumnHeaders = False
clvw.View = lvwReport
Dim uprocess As PROCESSENTRY32
Dim l As Long
Dim mm As MODULEENTRY32
Dim lm As Long
Dim modlvw As ListItem
l = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If l > 0 Then
uprocess.dwSize = Len(uprocess)
If Process32First(l, uprocess) Then
Do
'获得进程的标识符
lm = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, uprocess.th32ProcessID)
If lm > 0 Then
mm.dwSize = Len(mm)
If Module32First(lm, mm) Then
Do
If uprocess.th32ProcessID = mm.th32ProcessID Then
' Set modlvw = clvw.ListItems.Add(, , Text:=Str$(mm.szExePath))
'modlvw.SubItems(5) = mm.ProccntUsage
'modlvw.SubItems(4) = mm.szExePath
' modlvw.SubItems(3) = mm.hModule
' modlvw.SubItems(2) = mm.modBaseAddr
' modlvw.SubItems(1) = mm.modBaseSize
End If
Loop Until (Module32Next(lm, mm) < 1)
End If
CloseHandle (lm)
End If
Loop Until (Process32Next(l, uprocess) < 1)
End If
CloseHandle (l)
End If
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货