The most robust way to do that is with a Kernel object of some kind. For example, use a unique GUID for the name, and try creating a Mutex. The return value will tell you whether it was created, or if it opened one by that name that already existed. The latter means that another copy of your program beat you to it, and it is nicely atomic. The only race condition is that when the program quits there may be a small time when another process will see the mutex still there, before it is deleted. For user-launched applications, that is negligable.
You can use any kind of Kernal object that has a name and that is reference counted by processes rather than having a persistant existance. You can use something suitable for communicating back to the original to tell it to jump to the foreground, or open a new document, or whatnot; or just have all instances coordinate with each other.
—John
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.