New to VB Detecting another application running 
Author Message
 New to VB Detecting another application running

Hi,
     New to VB6, have written a small application that takes the PC time and
updates a small home controler time over the serial link.

I need to find some method of detecting if another application is running,
if so then shut this application down.

Hopefully someone can point me in the right direction.

Thanks for any help



Sun, 13 Jun 2004 11:17:18 GMT  
 New to VB Detecting another application running
On Wed, 26 Dec 2001 03:17:18 -0000, "johnMcc"

Quote:

>Hi,
>     New to VB6, have written a small application that takes the PC time and
>updates a small home controler time over the serial link.

>I need to find some method of detecting if another application is running,
>if so then shut this application down.

Which application ? :)
If you know the window name (better yet the class name), you can use
the FindWindow API to find the app's window.

Regards, Frank



Sun, 13 Jun 2004 12:58:24 GMT  
 New to VB Detecting another application running

Quote:
> Hi,
>      New to VB6, have written a small application that takes the PC time
and
> updates a small home controler time over the serial link.

> I need to find some method of detecting if another application is running,
> if so then shut this application down.

By "another application" do you mean a different application or another
instance of your own application? If you want to detect multiple instances
you can use

Sub Main()
    If App.PrevInstance Then
        MsgBox "Another instance of " + App.Title + " is already running.",
vbInformation
    Else
        frmMain.Show
End Sub

or similar. If you want to detect another application that you did not
write, see Frank Adam's suggestion.



Sun, 13 Jun 2004 13:10:16 GMT  
 New to VB Detecting another application running
Hi,
     The name of the application is Homevison, what I'm trying to do is
detect if it is running or not. The small application I created, runs at
03:am. Homevison can also be running to log what's happening with the home
controller.

Here what I have used so far.

Detect a Homevison program running

Err.Clear
On Error Resume Next
AppActivate "homevision"   ' I f Homevison is not running returns error 5

If Err.Number = 0 Then MsgBox "program running"
If Err.Number = 5 Then MsgBox "sorry not found"


Quote:


> > Hi,
> >      New to VB6, have written a small application that takes the PC time
> and
> > updates a small home controler time over the serial link.

> > I need to find some method of detecting if another application is
running,
> > if so then shut this application down.

> By "another application" do you mean a different application or another
> instance of your own application? If you want to detect multiple instances
> you can use

> Sub Main()
>     If App.PrevInstance Then
>         MsgBox "Another instance of " + App.Title + " is already
running.",
> vbInformation
>     Else
>         frmMain.Show
> End Sub

> or similar. If you want to detect another application that you did not
> write, see Frank Adam's suggestion.



Sun, 13 Jun 2004 19:56:47 GMT  
 New to VB Detecting another application running

Quote:
> Hi,
>      The name of the application is Homevison, what I'm trying to do is
> detect if it is running or not. The small application I created, runs at
> 03:am. Homevison can also be running to log what's happening with the home
> controller.

> Here what I have used so far.

> Detect a Homevison program running

> Err.Clear
> On Error Resume Next
> AppActivate "homevision"   ' I f Homevison is not running returns error 5

> If Err.Number = 0 Then MsgBox "program running"
> If Err.Number = 5 Then MsgBox "sorry not found"

Does it always have the same window caption, exactly? If so you can use
findwindow like this:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long

Public Property Get HomevisionRunning() as Boolean
    HomevisionRunning = (FindWindow(vbNullString, "Homevision Caption Goes
Here") <> 0)
End Property

If you have Visual Studio you can use the Spy++ tool to discover what the
classname of the main window is. If it sounds unique (not that #32770 is not
unique) then you could instead do:

Public Property Get HomevisionRunning() as Boolean
    HomevisionRunning = (FindWindow("HOMEVISION_CLASS", vbNullString) <> 0)
End Property

And of course if you know both the classname and the windowname (and you
know both are constant) you can combine the above two together to get:

Public Property Get HomevisionRunning() as Boolean
    HomevisionRunning = (FindWindow("HOMEVISION_CLASS", "Homevision Caption
Goes Here") <> 0)
End Property

I always prefer either both or just the classname over just a caption.

Hope this helps,

Jason



Sun, 13 Jun 2004 20:37:16 GMT  
 New to VB Detecting another application running

Quote:
>      The name of the application is Homevison, what I'm trying to do is
> detect if it is running or not. The small application I created, runs at
> 03:am. Homevison can also be running to log what's happening with the home
> controller.

If your home controller is an X-10 device using a CM11a interface, then
I'd suggest just bypassing the home-vision program, and sending a
command to your CM11a directly rather than using their resident
program.   It is a bit more complicated programming wise, but doesn't
rely on someone elses program being running.    E-mail for details.

 *****************************************************************
 *Bill Jones  N3JLQ  Sweden Maine                                *

 * Main home page   http://www.megalink.net/~wejones             *
 * WWII/B-17 page   http://www.megalink.net/~wejones/wwii.html   *
 *****************************************************************



Wed, 16 Jun 2004 00:11:25 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How do I detect Word 95 running with a VB 3 application

2. New User to VB - Inserting pictures into application at run time

3. Running a VB Application within another VB Application

4. How to detect if the application is running?

5. How to detect windows NT running application

6. How do I detect Word 95 running with VB3 application

7. How I detect if neede application is running?

8. Detecting running of application

9. Help Detecting Running Applications

10. how to detect which application running on the Windows NT

11. Detecting whether another application is running

12. Detecting a Running Application

 

 
Powered by phpBB® Forum Software