Con Mi Modulito Necesitas Un Timer...
Ex:
En un Modulo (BAS):
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
Public 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
en un Form Con 1 Timer
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
Me.BackColor = vbRed
End Sub
Private Sub Timer1_Timer()
If EstaCorriendo("calc.exe") Then
Me.BackColor = vbGreen
Else
Me.BackColor = vbRed
End If
End Sub
En Mi Ejemplo Si la Calculadora de Windows esta Avierta el Fondo del Formulario Se Vuelve Verde si La Calculadora (Proceso "calc.exe") esta Cerrada el Form Queda Color Rojo...