Solved

Don't let twice running

Posted on 2006-07-17
5
255 Views
Last Modified: 2010-04-16
Dear Experts

I wanna write an application if it runs, and user run it again (click on it icon), it doesn't create again and just show previous application as some programs, for example winamp, word and .... u cann't run winamp twice.it should check if it has runned previousely, don't run again
PLZ help me.

Regards
0
Comment
Question by:shaasousaa
5 Comments
 
LVL 9

Accepted Solution

by:
sun4sunday earned 50 total points
Comment Utility
check this
http://delphi.about.com/library/code/ncaa100703a.htm    //source code
http://delphi.about.com/od/windowsshellapi/l/aa100703b.htm // a neat explantion start here


In this article(with soure code) you'll learn how to "run-once enable"
a Delphi application that can check for its previous
(running) instance. Along the process, several techniques
of implementing such a check will be discussed; as well
as how to bring your already running application to the
foreground, if a user tries to run it "one more time". By
the end of the article you'll have a copy-to-go code to
control the behavior of your application's multiple instances:
with the option to limit the number of running instances.

sun4sunday
0
 
LVL 9

Expert Comment

by:sun4sunday
Comment Utility
0
 
LVL 17

Expert Comment

by:Wim ten Brink
Comment Utility
TJvAppInstances from the Jedo components (http://homepages.borland.com/jedi/jvcl/) will allow you to limit your application to a specific number of instances. It will also activate the running process if required and is just the simplest way. It also provides you some additional functionality that you might like to use. For example, it can transfer the commandline parameters from the second process to the first one.
0
 
LVL 7

Expert Comment

by:kfoster11
Comment Utility
Not sure where I downloaded this freeware control.

ADP Instance control.  Just drop it on the main form and tell it how many instances are allowed.

www.certss.com\downloads\expertexchange\adp.zip
0
 
LVL 6

Expert Comment

by:saravananvg
Comment Utility
Hello Sir,

  You could do as follows.


program Project1;

uses
  Windows, Messages, Forms,
  Unit1 in 'Unit1.pas' {MainWindow};

{$R *.res}

begin
if CreateMutex(nil, true, 'MyAppIsAlreadyOpened') <> 0 then
if GetLastError = ERROR_ALREADY_EXISTS then begin
  // app is already opened
  SetForegroundWindow(FindWindow('TMainWindow', 'MainWindow'));
end else begin
  // app is not opened
  Application.Initialize;
  Application.CreateForm(TMainWindow, MainWindow);
  Application.Run;
end;
end.

with regards,
padmaja.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now