[comp.lang.pascal] testing for sharing/locking ability

CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) (04/18/91)

I'm looking for straightforward, "foolproof" <g> ways to tell
whether MS-DOS file sharing and locking (compatible with SHARE.EXE)
is available on a given drive.

I've found two ways to make this determination, and I'm not
completely happy with either of them:

        1) Go ahead and open the file, then try to lock it (function
           $5C). If sharing/locking is not available, function $5C
           returns its error 1 (invalid function code).

        2) Call IOCTL (function $44) subfunction $0B to set the
           sharing retry count. If sharing is not available, it
           returns error 1.

I'm not happy with 1) because it requires me to open the file before
I know whether I can share/protect it appropriately.

I'd be happy with 2) if I knew a reliable, documented way to
determine the existing value of the parameter I was changing. (On
principle I'd want to restore the existing sharing retry count.)

Can someone here provide me a better method (or a pointer to one)
for determining the availability of sharing/locking, and/or a way to
get the existing value of the sharing retry count?

Thanks in advance--                     --Karl

+====================================================================+
| Karl Brendel                           Centers for Disease Control |
| Internet: CDCKAB@EMUVM1.BITNET         Epidemiology Program Office |
| Bitnet: CDCKAB@EMUVM1                  Atlanta GA  30093       USA |
|                        Home of Epi Info 5.0                        |
+====================================================================+