Checking Instance of Application

In article <>, says...


>How can I determine the instance number of an application.  Basically I want
>to know how many other times the application is currently running (either to
>only allow one to run at a time, or to allow a fixed number to be running at
>the same time).

the best way to do this is using the HInstance variable, which is declared
within one of the main modules.  I currently use this to make sure that the
various instances of the program running are not overlapping each other.  to
get the number of instances, the following code will suffice

        NumberOfInstances := GetModuleUsage(HInstance);

One other note, this should not be used before the HInstance has had the value
set, or your results may be off.  the best place I found is in the OnShow
event of a form.