Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Start application once

Posted on 1998-09-12
3
Medium Priority
?
160 Views
Last Modified: 2010-04-06
How can I prevent my application from being started twice? In Delphi 1 I could use the variable HPrevInst.

It's an MDI-application with various captions.
0
Comment
Question by:detempel
[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
3 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1339559
Several components exist, like this one:

http://bes.trendline.co.il/torry/vcl/system/bjustone.zip
"A component that enables only one unique instance of an application at each time."

There are several more on

http://bes.trendline.co.il/torry/system.htm, system2.htm, system3.htm, system4.htm

--Matvey
0
 
LVL 10

Accepted Solution

by:
viktornet earned 200 total points
ID: 1339560
Here is some code ;-)
----------
interface
uses Windows;
ResourceString
        AppCantStart = 'App is already running. Can not start another copy.';
        AppTitle = 'Just an App';
implementation
const
        TEN_SECONDS = 10000;
var
        MutexHandle : integer;
initialization
   MutexHandle := CreateMutex(Nil, False, 'DME Local Server Mutex.');
   if WaitForSingleObject(MutexHandle, TEN_SECONDS) <> WAIT_OBJECT_0
then
   begin
      MutexHandle := -1;
      Messagebox(0, PChar(RSCantStart), PChar(RSTitle), MB_OK);
      Halt;
   end;

finalization
        if MutexHandle <> -1 then
        ReleaseMutex(MutexHandle);
end.
--------------
Regards,
Viktor Ivanov
0
 

Author Comment

by:detempel
ID: 1339561
Adjusted points to 50
0

Featured Post

Independent Software Vendors: 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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

722 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