Autor
|
Tema: [Duda] detectar proceso activo (Leído 5,717 veces)
|
dashrender
Desconectado
Mensajes: 2
|
Hola amigos q tal.. tengo una duda ... si se podria detectar en vB tal proceso activo por ejemplo : svchost.exe ... si esta activo en un textbox q salga ON si no OFF
|
|
|
En línea
|
|
|
|
|
seba123neo
|
Hola, proba algo asi: Option Explicit Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function EnumProcesses Lib "PSAPI.DLL" (lpidProcess As Long, ByVal cb As Long, cbNeeded As Long) As Long Private Declare Function EnumProcessModules Lib "PSAPI.DLL" (ByVal hProcess As Long, lphModule As Long, ByVal cb As Long, lpcbNeeded As Long) As Long Private Declare Function GetModuleBaseName Lib "PSAPI.DLL" Alias "GetModuleBaseNameA" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long Private Const PROCESS_VM_READ = &H10 Private Const PROCESS_QUERY_INFORMATION = &H400 Private Function EstaCorriendo(ByVal NombreDelProceso As String) As Boolean Const MAX_PATH As Long = 260 Dim lProcesses() As Long, lModules() As Long, N As Long, lRet As Long, hProcess As Long Dim sName As String NombreDelProceso = UCase$(NombreDelProceso) ReDim lProcesses(1023) As Long If EnumProcesses(lProcesses(0), 1024 * 4, lRet) Then For N = 0 To (lRet \ 4) - 1 hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, lProcesses(N)) If hProcess Then ReDim lModules(1023) If EnumProcessModules(hProcess, lModules(0), 1024 * 4, lRet) Then sName = String$(MAX_PATH, vbNullChar) GetModuleBaseName hProcess, lModules(0), sName, MAX_PATH sName = Left$(sName, InStr(sName, vbNullChar) - 1) If Len(sName) = Len(NombreDelProceso) Then If NombreDelProceso = UCase$(sName) Then EstaCorriendo = True: Exit Function End If End If End If CloseHandle hProcess Next N End If End Function Private Sub Command1_Click() MsgBox EstaCorriendo("calc.exe") End Sub
saludos.
|
|
|
En línea
|
|
|
|
ricardovinzo
Desconectado
Mensajes: 135
P.T.C
|
|
|
|
En línea
|
3# Convocacion de Moderadores en Code Makers, entra!
|
|
|
Dessa
Desconectado
Mensajes: 624
|
hola dashrender, en el caso que en lugar de ser un proceso (como svchost.exe), busques una aplicación (oculta o visible), pòdes usar solamente FindWindows.
PD: Buen code Seba
Saludos
|
|
|
En línea
|
Adrian Desanti
|
|
|
dashrender
Desconectado
Mensajes: 2
|
hola seba123neo el codigo q me daste es genial funciona de maravillas.. me podrias ayudar en vez de que salga en msgbox "falso" o "verdadero" pueda salir en un label? pero que se actualize si ese "proceso" esta "activo" o "no" sin darle click ...
|
|
|
En línea
|
|
|
|
Dessa
Desconectado
Mensajes: 624
|
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function EnumProcesses Lib "PSAPI.DLL" (lpidProcess As Long, ByVal cb As Long, cbNeeded As Long) As Long Private Declare Function EnumProcessModules Lib "PSAPI.DLL" (ByVal hProcess As Long, lphModule As Long, ByVal cb As Long, lpcbNeeded As Long) As Long Private Declare Function GetModuleBaseName Lib "PSAPI.DLL" Alias "GetModuleBaseNameA" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long Private Const PROCESS_VM_READ = &H10 Private Const PROCESS_QUERY_INFORMATION = &H400
Private Function EstaCorriendo(ByVal NombreDelProceso As String) As Boolean Const MAX_PATH As Long = 260 Dim lProcesses() As Long, lModules() As Long, N As Long, lRet As Long, hProcess As Long Dim sName As String NombreDelProceso = UCase$(NombreDelProceso) ReDim lProcesses(1023) As Long
If EnumProcesses(lProcesses(0), 1024 * 4, lRet) Then For N = 0 To (lRet \ 4) - 1 hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, lProcesses(N)) If hProcess Then ReDim lModules(1023) If EnumProcessModules(hProcess, lModules(0), 1024 * 4, lRet) Then sName = String$(MAX_PATH, vbNullChar) GetModuleBaseName hProcess, lModules(0), sName, MAX_PATH sName = Left$(sName, InStr(sName, vbNullChar) - 1) If Len(sName) = Len(NombreDelProceso) Then If NombreDelProceso = UCase$(sName) Then EstaCorriendo = True: Exit Function End If End If End If CloseHandle hProcess Next N End If End Function
Private Sub Form_Load() Timer1.Interval = 300 Label1 = "" End Sub
Private Sub Timer1_Timer() If EstaCorriendo("calc.exe") = True Then Label1 = "ACTIVO" Else Label1 = "INACTIVO" End If End Sub
|
|
« Última modificación: 4 Marzo 2009, 18:05 pm por Dessa »
|
En línea
|
Adrian Desanti
|
|
|
|
Mensajes similares |
|
Asunto |
Iniciado por |
Respuestas |
Vistas |
Último mensaje |
|
|
Detectar finalización proceso contador de un programa.
Ingeniería Inversa
|
Mustakrakish
|
4
|
2,987
|
20 Diciembre 2010, 22:56 pm
por Mustakrakish
|
|
|
Detectar injeccio a un proceso.
Programación C/C++
|
Destro-
|
2
|
2,317
|
12 Enero 2011, 21:33 pm
por Destro-
|
|
|
Duda para detectar arp spoofing
Hacking
|
Frenes
|
4
|
4,659
|
24 Diciembre 2012, 23:13 pm
por adastra
|
|
|
Detectar antivirus activo desde cmd (Ayuda)
Windows
|
pilotcast
|
4
|
3,819
|
29 Abril 2013, 19:48 pm
por pilotcast
|
|
|
Detectar Proceso Padre (VB.net)
.NET (C#, VB.NET, ASP)
|
**Aincrad**
|
6
|
3,401
|
17 Marzo 2019, 20:56 pm
por **Aincrad**
|
|