TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Timo Sirainen
date: 1995-12-15 03:50:00
subject: File locking

Hello!

How can I use file locking commands with OS/2, like SHARE.EXE commands in
DOS. I'm using Virtual Pascal, and found these commands:

function DosSetFileLocks(
  F: HFile; var UnLock,Lock: FileLock; TimeOut,Flags: ULong): Apiret;
function DosCancelLockRequest(
  F: HFile; var Lock: FileLock): ApiRet;

So.. These HFile and TimeOut I understand, but what are those other ones?
And what can I put to Flags?

I tried something like this:

{------------------------}
var f: File;
    h: HFile absolute f;
    unlock,lock: FileLock;

begin
  unlock.lOffset:=0;        { What are these??? }
  unlock.lRange:=0;

  lock.lOffset:=0;     
  lock.lRange:=4;

  {...code...}
  DosSetFileLocks(h,unlock,lock,1,0); { Should be locked now?? }
  {...code...}
  DosCancelLockRequest(h,lock); { Unlocked?? Nah... }
  {...code...}
end.
{------------------------}

The weirdest thing in that is that 'unlock'.. What does that do? This program 
locks the file currectly(?), but then it won't cancel the lock, or at least 
next time I do this in same program, it gives some errors (File locking error 
or something). Why?

And this TimeOut, is it seconds? 1/100 seconds, or what?
--- Concord/BW POO1C3 (Reg.)
* Origin: Rampton Birds' Box, 931-3632951, 28.800bps (2:221/360)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 517 628 713/888 800/1 7877/2809
@PATH: 221/360 0 220/841 201/2104 109/347 716 13/25 396/1 270/101 712/515
@PATH: 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.