Record Locking lazarus / 61-Beginners ---------------------------------------------------------------------- Andy Anderson · 2014-08-10 21:29 I've read all the references I could find but couldn't find an example to put it all together. Can someone supply a link to an example of non OOP record/region locking? Thanks in advance. ---------------------------------------------------------------------- Andy Anderson · 2014-08-13 17:02 Well, I guess there is no way in Free Pascal to lock/unlock records/regions for Windows OS's. My workaround will be to use the LOCKFILEEX/UNLOCKFILEEX API's. ---------------------------------------------------------------------- Laksen · 2014-08-13 17:28 It depends on what you need. If you need to lock a shared variable you can use critical sections, mutexes, semaphores, or events. Critical sections are probably by far the simplest to understand. You can take a look at the syncobjs unit to see some easy to use object oriented classes for this. Edit: Ah, if you need non-OOP code you can also take a look at that unit. It uses the standard platform independent interface in the RTL to do the different things. For example, a critical section: Code: [Select]var cs: TRTLCriticalSection;    // Call this to initialize    InitCriticalSection(cs);    // And this when you are done with it    DoneCriticalSection(cs);    // And to lock some resource    EnterCriticalSection(cs);    ... do stuff with whatever needs locking    LeaveCriticalSection(cs); The CS variable would be a single lock that only prevents others from entering the same. So you will want one for each thing that you are locking. ---------------------------------------------------------------------- Andy Anderson · 2014-08-15 19:07 Thanks, Laksen. I'll take a look at the critical sections material. Curiously, the Windows API's I mentioned require a type specification almost identical to the Unix based FLock type for the FpFcntl call.