
Checking if drive is remote (networked)
I think someone asked for a way to check whether (logical) disk drive is
on network or not. That can be done by checking if drive is remote, and
there is DOS function (DOS 3.1+) that do just that. Here is code for
function IsRemote() (note that there is function in FUNCky with the
same name, that do just the same thing:) which requires drive letter
("C", "D",.. - just letters without ":") and returns 1 if drive is
remote (networked), 0 if it's not and -1 if error occured.
/*
* File......: IsRemote.Prg
* Author....: Jovan Bulajic
*
* This function checks whether drive is remote or not, which can
* be used to detect if specified drive is local or on network.
* Requires NanForum library.
*
* This is an original work by Jovan Bulajic and is placed in the
* public domain.
*/
#include "ftint86.ch"
**** ---------------------------------------- ****
function IsRemote (cDrive)
local aRegs[10], nDrive, nResult
if ! Empty(cDrive)
// DOS functions uses drive number (01h, 02h,...)
// rather than drive letters (C, D,..) so we have
// to convert letters to numbers
nDrive := Asc(cDrive) - Asc("A") + 1
else
// no drive is specified, so we use default drive
nDrive := 0
endif
aRegs [ AX ] := FT_Hex2Dec ("4409") // subfunction 0x4409
aRegs [ BX ] := nDrive // BL is drive number
FT_Int86 (FT_Hex2Dec ("21"), aRegs) // DOS Int 21h
// on return CF is set on error (I'm not checking that here, but
// it can be easilly changed if we make function to return numeric
// response (eg. 0 for not
do case
case CarrySet (aRegs[FLAGS])
// CF is set on error, you can get erorr code in AX
nResult := -1
case aRegs[DX] == 4096
// drive is remote if 12. bit is set (2^12 == 4096)
nResult := 1
otherwise
// not remote
nResult := 0
end case
return nResult
--
Jovan Bulajic
Belgrade, Yugoslavia