Solved

Don't let twice running

Posted on 2006-07-17
5
263 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
ID: 17120094
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
ID: 17120099
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 17120264
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
ID: 17123021
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
ID: 17127986
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 304
Delphi selector screen 2 79
Delphi Form ownership 4 89
Not able to call Delphi XE10 dll function from Delphi 6.0 4 26
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 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