Solved

Instances in Delphi 2

Posted on 1997-07-03
2
200 Views
Last Modified: 2010-04-06
How do I make sure my program will not run another instance of itself?
0
Comment
Question by:Evil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 1

Accepted Solution

by:
Gabor earned 50 total points
ID: 1338148
The easiest way is to use a so called global atom.When your program starts you can look for your unique global atom to determine if your program is already running with then following line:- if GlobalFindAtom('MyProgramsUniqueAtom')=0 then begin    {not running}    {Let's make the atom, because this instance is the first}    GlobalAddAtom('MyProgramsUniqueAtom');  end else begin    {running}    {You can close your current instace here for example}  end;Before your (unique) instance finished you have to free the global atom with this line:- GlobalDeleteAtom(GlobalFindAtom('MyProgramsUniqueAtom'));This clears the atom, so you can now rerun your application.
0
 
LVL 1

Expert Comment

by:Gabor
ID: 1338149
Sorry Evil, but my CR-s disappeard. I don't know why.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question