'Deklarationen zum Kontrollieren, ob ein Task (Finder) noch läuft
'Deklarations for controlling
Private Declare Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal _
dwDesiredAccess As Long, ByVal bInheritHandle As _
Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Private Const STILL_ACTIVE = &H103
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
'Enthält die TaskID des Empfangprogramms
'Contains the taskID
Private TaskIDFinder As Double
Private Const cfinder = "C:\Support\Finder.exe"
'controlling code in Timer Event
If Not IsActiveFinder Then
TaskIDFinder = Shell(cfinder, vbNormalFocus)
End If
'Kontrolliert, ob Finder noch läuft
'Controls, if finder still active
Private Function IsActiveFinder() As Boolean
Dim Handle&, ExitCode&
Handle = OpenProcess(PROCESS_ALL_ACCESS, False, TaskIDFinder)
Call GetExitCodeProcess(Handle, ExitCode)
Call CloseHandle(Handle)
IsActiveFinder = IIf(ExitCode = STILL_ACTIVE, True, False)
End Function
--
Gruss
Karsten
- Ideen aus Folie -
http://www.cd-design.de
Bertman <Bertman@home.nl> schrieb in im Newsbeitrag:
K%Xv7.21236$fo2.2748250@zwoll1.home.nl...
> Hello,
>
> I have to make a program that checks if a program is active. For example:
My
> program starts Calc.exe, and my program have to check every 10sec if
> calc.exe is still active. And when you close Calc.exe then de VB program
> have to give a message.
>
> But I don't know how to check if calc.exe is active.
> I'm using VB 6.0 with SP5
>
> Bertman
>
>