Preventing Multiple Launches of the same App 
Author Message
 Preventing Multiple Launches of the same App

I've written a program which reads the results from an HP meter.
However, my users tend to launch several copies of it, and when two
copies are trying to read the meter, the whole system locks.  I'd like
to know of a simple way to tell if a copy is already running, and task
switch to that copy if the program executed.  Thanks for any help.

Jeff



Wed, 02 Jan 2002 03:00:00 GMT  
 Preventing Multiple Launches of the same App
use following code in your Sub Main startup procedure :

If App.PrevInstance = True Then
   MsgBox "Application is already running"
   End
End If

this will prevent a second copy of your application to start

by the way , check the App object, it has some other usefull information
about the application.

bernd


Quote:
> I've written a program which reads the results from an HP meter.
> However, my users tend to launch several copies of it, and when two
> copies are trying to read the meter, the whole system locks.  I'd like
> to know of a simple way to tell if a copy is already running, and task
> switch to that copy if the program executed.  Thanks for any help.

> Jeff



Wed, 02 Jan 2002 03:00:00 GMT  
 Preventing Multiple Launches of the same App
Ok I too wanted to stop multiple instances of the same app and to swap to
the current app without restarting a new instance. I have tried numerous
different methods but this seems too work best for my apps.

Using the Main sub as your start up sub then checking to see if the
application is already running;
if it is    -  then activate and place on top of the desktop, then end the
second app should never actually be seen by user.

if not    - then show the main form which in turn will execute its
initialize, activate, and load routines as usual.

Heres the code I use. N.B: appactive needs a string or string variable of
the Form caption of the instance you want to swap to.

Private Sub Main()
If App.PrevInstance = True Then
    AppActivate "Your Main form Caption here"
    End
Else
    MainFrm.Show
End If
End Sub

Clear as mud?

Christopher Hyett
Imaginative Solutions

Quote:

>I've written a program which reads the results from an HP meter.
>However, my users tend to launch several copies of it, and when two
>copies are trying to read the meter, the whole system locks.  I'd like
>to know of a simple way to tell if a copy is already running, and task
>switch to that copy if the program executed.  Thanks for any help.

>Jeff



Wed, 02 Jan 2002 03:00:00 GMT  
 Preventing Multiple Launches of the same App
On Sat, 17 Jul 1999 08:22:44 +0200, "bernd samaille"

Quote:

>use following code in your Sub Main startup procedure :

-snip-
Thank you very much!  I've been banging my head into a wall for a week
trying to get this solved!  I just wanted to say thanks to you and to
Christopher, who also responded.  

Jeff Hill



Wed, 02 Jan 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Preventing multiple copies of App

2. Help preventing Multiple Instances of an App..

3. Launching Multiple threads from VB app / hide process in task list

4. Launching vb app when IE launch

5. Reset screen so taskbar app prevents maxed apps from displaying underneath

6. Reset screen so taskbar app prevents maxed apps from displaying underneath

7. Launching 16-Bit apps from 32-Bit app?

8. Web app launching a legacy app

9. Launching MS App from within VB app

10. How to launch and kill an app from my app

11. Launching eVB app from eVB app...

12. CAB questions: 1) run app after install 2) installed multiple apps

 

 
Powered by phpBB® Forum Software