rejetto forum

[HELP] only 1 instance

0 Members and 1 Guest are viewing this topic.

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
i want to make this feature

as far as i got, when a new instance is started, i have to use DDE to pass datas to the old instance, then terminate

the problem is: i'm not able to use DDE in delphi, i spent several hours on it, but...ugh...nothing

please help


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
after 4 months, leo suggested me to use WM_COPYDATA
i will try later


Anonymous

  • Guest
i think its no problem if there will be only one instance


Anonymous

  • Guest
can you use mutex?

http://www.google.com/search?q=mutex+instance+delphi

http://www.ibrtses.com/delphi/singleinstance.html

i played with a delphi dde demo some time ago
it created a window with a counter
the second program used dde to connect to the first program
and transferred the count using dde
so the second window was counting in sync with the first

it seemed like a lot of code to do something so simple

linux apps often uses lock files
the first instance of hfs would check to see a file called C:\HFS.LOC exists
if it doesn't, it starts and creates the file
a second instance of hfs would see the lock file, and shut down
when the first instance shuts down, it deletes the lock file
the trouble is, if hfs crashes, the lock file may not be deleted
this happens to linux apps sometimes ... you have to delete the lock file to start the app again


Anonymous

  • Guest
if you want to prevent a new instance maybe you can use mutex

if you want to pass information from the old to the new
then shut down the old
maybe a temp file or registry key could pass the parameters
like C:\~HFS.TMP maybe
it would require hfs to watch for the creation of the file

i guess dde would be a more elegant method


Anonymous

  • Guest
would a component like this work?

http://www.torry.net/instance.htm

OneInstance v.2.3    FWS   5 Kb

By Andrew Johnson. To allow only a single instance of an application - can warn user, terminate new instance, use custom handler, and/or Raise Former Instance of Application when another instance is found. Simply drop one on your main form.
 
Fully functional
Source: Included

if the licence is not suitable, you can see how it works and write your own


Anonymous

  • Guest
how about this?

http://www.programmersheaven.com/zone2/cat69/29762.htm

Multiinstance 1.1
TMultiInstance component controls behavior of multiple intances of the same program. Default allows only one instance of program. Next instance terminates immediatly. Behaviour is configurable in program.

Language:    Delphi 5-6-7
Platform:    Windows 2000-95-98-CE-ME-NT-XP
File type:    Open Source
Size:    3 KBytes
Price/fee (US$):    0.00$



Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
Quote from: "Suicide"
i think its no problem if there will be only one instance
it won't be a problem
it will be a feature
:)


many thanks Guest, i will have a look at those resources