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

x
?
Solved

Don't let twice running

Posted on 2006-07-17
5
Medium Priority
?
288 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
[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
5 Comments
 
LVL 9

Accepted Solution

by:
sun4sunday earned 150 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
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 …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

661 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