Jason,

There are several approaches:

1.  If all the apps run on the same machine then:

Create a mutex.
Create a named shared memory area
Use the mutex to gain exclusive access to the memory area.

2.  If the apps reside on different machines:

Create an app that is the server for a mail slot.  Put this on a machine in
the domain.
When an app wants a unique number, the app writes to the mail slot.  Since
mail slots are queued, the server app will read out the message in sequence.
The server can then generate the unique number for return to the apps.  This
can be done via a pipe, socket, file, table, etc.

3.  If the apps use a database server, use the server's number generation
function to return unique numbers.  Eg. GENERATORS in Interbase.


Hope this helps.
Dennis.


> I hope someone has some ideas as I'm stuck.
>
> I have a situation where two delhi programs need to obtain an incrimenting
> unique ID number from the single source.
>
>
> So an example.
>
> Delphi progrm 1 processes and gets unique ID 1000
> Delphi program 2 processes and gets inque ID 1001
> Delphi progrm 1 processes and gets unique ID 1002
> Delphi program 2 processes and gets inque ID 1003
> Delphi progrm 2 processes and gets unique ID 1004
> Delphi program 2 processes and gets inque ID 1005
> and so on....
>
> So it's reasonably easy to use a single ini file or share a registry entry
> but what hapens when both programs want to get a unique ID at the
> same time.
>
> In future I'll have more delhi programs that need to get the
> uniqie ID form
> the same source.


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to