if checkLockout() * tell user too bad charlie brown and exit endif if not CheckOpenUsers() * licenses all used up, too bad again, exit endif if oUser.gnControlRecord = 1 * make sure backup was run properly, if so go ahead, if not, roo bad charlie brown endif ....... ...... if LogOutLast() do some backup endif PROCEDURE CheckOpenUsers * ----------------------------------------------------------------------------- * There should be a free table in the data folder called vmcontrol. * That table has the exact number of records as the user has licenses. Each login * locks one record. Quitting vmanager loses the lock, so no orphaned logins * * The previous function of CheckLicenseFile made sure correct number of record * were in vmcontrol, so if that is not true here, we will have to quit. * --------------------------------------------------------------------------- LPARAMETERS tLoginName IF NOT USED('VMCONTROL') USE (oVM.gcDataPath + 'vmcontrol.dbf') SHARED IN 0 ENDIF SELECT vmcontrol COUNT FOR NOT DELETED() TO lnC * ---------------------------------------------------------------- * # of records equals what system.dbf reports as # of licenses. * So we will try and lock one record. If all records already locked, * then max users logged in. Quitting automatically releases the * record lock, so ghost logins impossible. * --------------------------------------------------------------- IF lnC = oVM.gnMaxUsers SCAN IF RLOCK() * OK, folks, we do not know the user name yet! REPLACE field1 WITH tLoginName REPLACE field2 WITH SYS(0) && machine/user name oUser.gnControlRecord = RECNO() RETURN .T. ENDIF ENDSCAN ENDIF * --------------------------------------------------------- * * only get here if was right number of records for user license, * but we could not get a lock because max people on already. * --------------------------------------------------------- RETURN .F. Procedure LogOutLast IF NOT USED('VMCONTROL') USE (oVM.gcDataPath + 'vmcontrol.dbf') SHARED IN 0 ENDIF SELECT vmcontrol * we should be able to lock every record if we are the only ones in the app SCAN for recno() <> ouser.gncontrolrecord if not rlock() return .f. endif endscan return .t.>in the multiusers environment, I want to set an automatic backup, after the last user logout.