Announcement

Collapse
No announcement yet.

Ensuring only one instance of a program – how?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Erik Christensen
    replied
    I managed to produce this code based on previous contributions in the PowerBasic Forum. Thanks a lot.
    http://www.powerbasic.com/support/pb...d.php?p=303356

    Leave a comment:


  • John Petty
    replied
    Eric
    Just a reminder this is not as simple as it sounds if you are in a situation with multiple name spaces such as when running with Terminal Services or Citrix or even with XP or Vista with fast user switching as unless exceptionally careful many of the normally checked objects will only be visible in a single namespace.
    Some discussion here http://www.powerbasic.com/support/pb...ad.php?t=37884
    John

    Leave a comment:


  • Erik Christensen
    replied
    I just found this link:

    http://www.powerbasic.com/support/pb...ad.php?t=24019

    I think this will answer my question.

    Leave a comment:


  • Erik Christensen
    replied
    Thanks.

    I found a similar function in this thread:
    http://www.powerbasic.com/support/pb...ad.php?t=25148

    This prevents more than one instance, which is fine.

    If for some reason there are already more instances of a program, is it then possible to delete (by another program) the superfluous ones?
    Last edited by Erik Christensen; 29 Nov 2008, 10:58 AM.

    Leave a comment:


  • Mel Bishop
    replied
    Check my MP3 player at:

    http://www.powerbasic.com/support/pb...ad.php?t=25095

    and look for the Is_Already_Running function

    Leave a comment:


  • Erik Christensen
    replied
    I want to do something to make sure that only one instance of my own program exists at any time (i.e. kill a second (third and so on ..) instance).

    I think the technique you describe Guenther is fine. I will try this. Thank you.
    Last edited by Erik Christensen; 29 Nov 2008, 08:49 AM.

    Leave a comment:


  • Guest
    Guest replied
    ?

    Eric,

    Is there a simple method by which a program can ensure that there at any time is only one instance of another program running?
    Do you want to ensure, there is only one instance of your own program
    running at a given time, or there is only one instance of a third
    party program running at a given time.

    What do you mean by ensure?
    - just look to make sure (count instances)
    - do something to make sure (kill a second (third and so on ..) instance)


    Ensuring your own program runs only in a single instance is very easy.
    You need some kind of a global flag (a file, a .ini file, a memory mapped
    file, a mutex, a registry entry, ...). When your program starts, it must
    check, if this flag is set. If so - it must abort (because there is already
    another instance running), if not - it must set this flag by itself to prevent
    other instances from running. When exiting don´t forget to reset this flag
    again.


    Hope this helps


    guenther

    Leave a comment:


  • Michael Mattias
    replied
    Multiple examples here.

    Search 'mutex' and/or 'instance' in message subject.

    Leave a comment:


  • Ensuring only one instance of a program – how?

    Is there a simple method by which a program can ensure that there at any time is only one instance of another program running? Thanks in advance.

    Best regards,

    Erik
Working...
X