TAppInstance -
Register - MaxInstances,
{ if not assigned an exeption is raised
TInstance
TInstanceEvent
TUserName
E_CONTROL_FILE_CHANGE
E_INTERNAL_ERROR
E_INVALID_CONTROL_FILE
E_LOCK_TIMEOUT
E_TO_MANY_INSTANCES
E_TO_MANY_USERS
E_USERNAME_CHANGE
E_WRITE_ERROR
LOCK_OFFSET
LOCK_TIMEOUT
procedure Register;
MaxInstances,
{ if not assigned an exeption is raised
TInstance = record
UserName : TUserName;
LoginTime : TDateTime;
LogoutTime : TDateTime;
Active : Boolean;
end;
TInstanceEvent = procedure (var AInstance : TInstance) of object
TUserName = String [20]
E_CONTROL_FILE_CHANGE = 'ControlFile can not be changed when Active = True'
E_INTERNAL_ERROR = 'Internal error in TAppInstance'
E_INVALID_CONTROL_FILE = 'Could not open or create "%0:s"'
{$DEFINE DEUTSCH}
by
Thomas Schubbauer, Vienna (Austria)
e-mail: 100640.1021@compuserve.com
homepage: http://ourworld.compuserve.com/Homepages/SchubbT
this unit is freeware
comments welcome
written with Delphi 3, should work with Delphi 2
TAppInstance is a component, to check how many instances of an
application are running, and if a program was not correctly terminated.
All instances of an application must use the
same control-file (ControlFile-property).
E_LOCK_TIMEOUT = 'Could not lock "%0:s"'
E_TO_MANY_INSTANCES = 'To many active instances'
E_TO_MANY_USERS = 'To many active users'
E_USERNAME_CHANGE = 'UserName can not be changed when Active = True'
E_WRITE_ERROR = 'Could not write to "%0:s"'
LOCK_OFFSET = $80000000
LOCK_TIMEOUT = 5.0