2011-06-21 57 views
0

如何使用「ReadProcessMemory」API循環遍歷機器的所有正在運行的進程,並掃描字符串Array並返回true/false值,如果內存中包含任何一個或多個該過程 - 使用VB6?循環所有進程內存

例子:

Strings() = {"@[email protected]", "@[email protected]", "$TRING"} 
Loop # Processes 
    If InStr(ProcessMemory(#), Strings) Then 
     MsgBox(Process(#) & " Contains one of the strings!") 
    End If 
Loop 

回答

1

我不知道,但我使用WMI在我的計劃

東西

Public Sub KillProcess(ByVal processName As String) 

On Error GoTo ErrHandler 

Dim oWMI 
Dim ret 
Dim sService 
Dim oWMIServices 
Dim oWMIService 
Dim oServices 
Dim oService 
Dim servicename 

Set oWMI = GetObject("winmgmts:") 
Set oServices = oWMI.InstancesOf("win32_process") 

For Each oService In oServices 

    servicename = LCase$(Trim$(CStr(oService.Name) & "")) 

    If InStr(1, servicename, LCase(processName), vbTextCompare) > 0 Then 
     ret = oService.Terminate 
    End If 

Next 

If Not oServices Is Nothing Then Set oServices = Nothing 
If Not oWMI Is Nothing Then Set oWMI = Nothing 


ErrHandler: 
    Err.Clear 

End Sub 
+0

另一個很好的理由是如何離開禁用WMI服務。 – Bob77