PROCEDURE CheckForExclusive LOCAL lcTable, llExclOK lcTable = <path> + <tablename> && This is whatever path and table TRY USE (lcTable) IN 0 ALIAS excltest EXCLUSIVE llExclOK = .T. SELECT excltest && Not sure if you want to close here or USE && at end of program CATCH TO loException llExclOK = .F. ENDTRY RETURN llExclOK ENDPROCYou can call this as appropriate for your application. You can also do this with a small file. Open it with FOPEN() and this will work. You can set the FOPEN handle to a global attribute:
PROCEDURE CheckForExclusive LOCAL lcFile IF !PEMSTATUS(_VFP,"ExclusiveUse",5) ADDPROPERTY(_VFP,"ExclusiveUse",0) ENDIF lcFile = <path> + <Filename> && This is whatever path and file TRY _VFP.ExclusiveUse = FOPEN(lcFile,0) CATCH TO loException _VFP.ExclusiveUse = -1 ENDTRY ENDPROCThen before the program closes, or whenever you don't want to have exclusive use, perform the following:
PROCEDURE ReleaseExclusive =FCLOSE(_VFP.ExclusiveUse) _VFP.ExclusiveUse = 0 ENDPROCYou can always check the status of exclusive access via the _VFP.ExclusiveUse being set to positive value.