Board index » delphi » One instance of APP only
Don Schoeman
![]() Delphi Developer |
Sun, 21 Jul 2002 03:00:00 GMT
|
Don Schoeman
![]() Delphi Developer |
Sun, 21 Jul 2002 03:00:00 GMT
One instance of APP only
In the TI documents provided by Borland/Inprise, an example is given on how
to get an application to stop a second instance of itself being executed. This example doesn't seem to work in Delphi 4. Is there any other way of Thanks! |
Igor Popo
![]() Delphi Developer |
Tue, 23 Jul 2002 03:00:00 GMT
Re:One instance of APP onlyI don't know anything about TI documents, but why don't U try this: work with registry: program only bad thing that could happen here is power failure, which would dissable p.s. this code isn't tested. QuoteDon Schoeman wrote in message <3898982...@news1.mweb.co.za>... |
lexi
![]() Delphi Developer |
Wed, 24 Jul 2002 03:00:00 GMT
Re:One instance of APP onlyIgor Popov wrote in <7439ACA52032D311A96200400537EC0FAF6...@ns1.tehnicom.net> ... Quote>work with registry: more nice apps. Even if anyone would choose this mechanism, I do not think using registry for doing this is a good idea - there are lots of more convenient ways = for example global atoms etc. So, DON'T work with registry. I've posted mutex example - it works and it's Bye. |
Johan Sm
![]() Delphi Developer |
Wed, 24 Jul 2002 03:00:00 GMT
Re:One instance of APP onlyOn Wed, 2 Feb 2000 22:49:00 +0200, "Don Schoeman" <dpds...@mweb.co.za> wrote: Quote>In the TI documents provided by Borland/Inprise, an example is given on how From my carefully hoarded help file: To stop your program from being run more than once: Declare a global variable to your unit: var atom : word; on you mainforms OnCreate Event put this..... procedure TForm1.OnCreate(sender : Tobject); begin if GlobalFindAtom('PROGRAM_RUNNING) = 0 then begin {Search the global atom table for the program thats running} atom := GlobalAddAtom('PROGRAM_RUNNING'); {add it to the table if its not found} end else begin MessageDlg('Program is already Running!',mtWarning,[mbOK],0); {if its found, show a message} Halt; {and halt the running of another instance of the program} end; end; And on the programs on destroy event procedure TForm1.OnDestroy(Sender : TObject); begin GlobalDeleteAtom(atom); {remove it from the global atom table} end; (Ek gebruik dit in Win95, maar ek weet nie of die global atom list in function IsPrevInst: Boolean; // Then we find the preceeding instance's main window, The easiest way is to use a mutex. Put the following code at the end Kies enigeen. |
Bruce Robert
![]() Delphi Developer |
Wed, 24 Jul 2002 03:00:00 GMT
Re:One instance of APP onlyQuote"Igor Popov" <i...@tehnicom.net> wrote in message Quote> I don't know anything about TI documents, but why don't U try this: There are TIs that answer a large variety of questions. I highly recommend scanning through the list periodically. Quote
|
Mark Shapir
![]() Delphi Developer |
Wed, 24 Jul 2002 03:00:00 GMT
Re:One instance of APP onlyWill the mutex code prevent two users on separate computers from starting the same program from a network drive? |
Bob Fol
![]() Delphi Developer |
Thu, 25 Jul 2002 03:00:00 GMT
Re:One instance of APP onlyIn article <0dgo9sor81k47ng4f4398idjm9t84dq...@4ax.com>, Mark Shapiro Quote<info...@swbell.net> writes: HTH Bob |