shaasousaa
asked on
Don't let twice running
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
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
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(FindWi ndow('TMai nWindow', 'MainWindow'));
end else begin
// app is not opened
Application.Initialize;
Application.CreateForm(TMa inWindow, MainWindow);
Application.Run;
end;
end.
with regards,
padmaja.
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(FindWi
end else begin
// app is not opened
Application.Initialize;
Application.CreateForm(TMa
Application.Run;
end;
end.
with regards,
padmaja.
https://www.experts-exchange.com/questions/21653129/I-need-a-function-to-check-if-my-program-is-already-open.html
sun4sunday