LockFile

Demonstrates how to lock a file.

Remarks

This example illustrates how to lock a file for exclusive access to the file.

Code

 local integer tfid
 local int success 
 local string temp_file

 try
    temp_file = "./my.pix"
    delete temp_file noerror
    call CopyFile( GetPCIHOME() + "/demo/irvine.pix", \
                 temp_file)

    tfid = DBOpen(temp_file, "r+")

    success = LockFile(tfid, 1)
    print "Success ", success
    call UnlockFile(tfid)
    call DBClose (tfid)
 onerror
   print "Error: "+ GetLastErrorMessage()
 endonerror

Output

 Success 1        File cannot be accessed by another process.

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.