Difference between revisions of "UniqueInstance"

From Lazarus wiki
Jump to navigationJump to search
Line 44: Line 44:
 
=== Download ===
 
=== Download ===
  
[Here http://www.geocities.com/camara_luiz/uniqueinstance-0.1.zip]
+
[http://www.geocities.com/camara_luiz/uniqueinstance-0.1.zip Here] and from [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=215290 Lazarus CCR sourceforge].

Revision as of 21:50, 16 December 2006

About

UniqueInstance provides an easy way to force only one instance per application running at same time.


Features

  • Easy of use: just drop a component in the main form
  • Provides a mechanism to receive the Command Line of the other instances

How To Use (Component)

Just drop in the main form

Properties:

  • Enabled: enables/disables the component
  • Identifier: used to provides a way to identify the application

Event

  • OnOtherInstance: called when another instance is initiated. Receives the parameters passed to that instance.

How To Use (Raw)

Add uniqueinstanceraw unit to your uses section.

Call the InstanceRunning function: it will return true if there's already a instance running. There are two variants: one with an Identifier argument (String) and one without. The second will use the executable name as the Identifier.


Remarks

  • It was developed and tested under win32. I don't have a Linux machine at time
  • Although it does not use platform dependent code, the callback mechanic used to pass the command line probably won't work in Linux. This occurs because TSimpleIPCServer under Linux does not call the OnMessage event (At least until some months ago when i tested it).
  • If you put two TUniqueInstance components in the same application with the same identifier your application wont load.
  • The Identifier is optional both to the function and the component. In the case it's not used, the executable name is used as a Identifier. The consequence is that if someone changes the exe name another instance will not be identified.

Author

Luiz Américo Pereira Câmara


License

Modified LGPL


Download

Here and from Lazarus CCR sourceforge.