🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.basic.visual
3 messages
3 total messages Started by Bertman Sun, 07 Oct 2001 12:34
A active program !
#270
Author: Bertman
Date: Sun, 07 Oct 2001 12:34
11 lines
1727 bytes
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
Re: A active program !
#263
Author: Mike Labosh
Date: Mon, 08 Oct 2001 19:34
36 lines
2461 bytes
You use the FindWindow API function to get the window handle of the window
you want.  Then you call GetWindow in a loop until it returns 0, then you
know the other window has been closed:

lHwnd = FindWindow(...)

While GetWindow(...) <> 0
    DoEvents
Wend

In your case, if you wish to poll every x seconds, you can put the above
code in the timer event of a control and modify it so that it does something
else when the window disappears, or you could call the Sleep API function
instead of DoEvents.

--
Peace and happy computing,

Mike Labosh, MCP, MCT, MCSD
"Hit any user to continue."
"Bertman" <Bertman@home.nl> wrote in message
news: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
>
>
Re: A active program !
#264
Author: Karsten R�ttger
Date: Tue, 09 Oct 2001 12:28
58 lines
2955 bytes
'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
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads