Link to home
Start Free TrialLog in
Avatar of nafa2221
nafa2221

asked on

Dupelicate Instantces

How do I check my program for duplicate instantaces??? Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nafa2221
nafa2221

ASKER

that was somewhat confusing, can u post an example and where I would post the code, also can u tell me howto get to the area I am supposed to post my code? Thanks!!!
Avatar of kretzschmar
hi nafa2221,

a simple method
(modification in the dpr-file)

program itTimer;

uses
  windows,
  Forms,
  Dialogs,
  itGlobal in 'itGlobal.pas',
  ufrmTIMER in 'ufrmTIMER.pas' {frmTIMER},
  doitAPI in 'doitAPI.pas',
  ufrmTIMERUpdate in 'ufrmTIMERUpdate.pas' {frmTimerUpdate},
  ufrmTIMERShow in 'ufrmTIMERShow.pas' {frmTimerShow},
  ufrmTimerSub in 'ufrmTimerSub.pas' {frmTimerSub},
  ufrmErrorReport in 'ufrmErrorReport.pas' {frmErrorReport},
  ufrmprobtimer in 'ufrmprobtimer.pas' {frmProblemeTimer};

{$R *.RES}

var StartUpH : THandle;

begin
  StartUpH := FindWindow(PChar('TfrmTIMER'),PChar('inTIME · Timer'));
  if (StartUpH <> 0) and (ParamStr(1) <> 'Test') then  //no testenviroment
  begin
//    ShowWindow(StartUpH,SW_SHOW);
    MessageDlg('itTimer ist bereits gestartet!',mtInformation,[mbOK],-1);
  end
  else
  begin
    Application.Initialize;
    Application.Title := 'inTIME · Timer';
    Application.CreateForm(TfrmTIMER, frmTIMER);
  Application.CreateForm(TfrmTimerUpdate, frmTimerUpdate);
  Application.Run;
  end;
end.

meikl
Try this (put the code in .DPR file)

var Handle1: HWND;

begin
  Application.Initialize;
  Handle1 := FindWindow('TfrmMain','Caption');
  if (Handle1 = 0) then begin
    Application.CreateForm(TfrmMain, frmMain);
    ...
    Application.Run;
  end
  else
    ShowMessage('App already running!');
end.

Obs: 'TfrmMain' = Class of Main Form
     'Caption' = Caption on Main Form

cheers,

Fulvio.
Fulvio, would you mind to withdraw your answer since other solutions have been given before you...?
No problem Epsylon!

What happend was when I posted it I didn't see the other solution (just 3 min. before)

See you,

F.
Yup, I see   :o)
Hi Epsylon, please, could you answer me why a lot of people offers the answer like a comment, what's the advantage?
And about the point? How they won the points?

I'm new in the site and never understood it :o)

Thanks in advance,

Fulvio.
Fulvio, when you're sure that the answer is correct AND your're the first one then you could submit it as answer. But when someone else has already given a (partial) solution, submit it as comment. This is an unwritten(?) rule here at EE...
Thanks Epsylon! :o)