PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: LockFileEx  (Read 657 times)

Richard Kelly

  • Senior Member
  • ***
  • Posts: 332
LockFileEx
« on: May 11, 2011, 06:58:58 AM »

With the app I'm writing, I want to offer single and multi user licenses. What I'm looking at doing is to have a special file that is in the same folder as my SQLite3 database and write a combination of computer name/user id to it. I wanted to use LockFileEx to place a lock of the starting byte of each session slot that contains the computername/userid. If I do that using LockFileEx and say, the program or even the computer crashes will Windows release the lock? MSDN says that locks are released when the file is closed normally, When checking for current valid users, I was thinking of scanning the session slots and trying the LockFileEx on them, and if it succeeds then that session slot is invalid and does not factor into the tally of current active users.

I did look at the PB LOCK/UNLOCK commands. If does say all locks have to be removed via UNLOCK before a file can be closed which could be problematic in that I'd have to keep track of things in each program instance. Probably can be done....

Thoughts?

Rick Kelly
« Last Edit: May 11, 2011, 07:04:38 AM by Richard Kelly »
Logged