Checking if drive is remote (networked) 
Author Message
 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 ""

**** ---------------------------------------- ****
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
        // no drive is specified, so we use default drive
        nDrive := 0

    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
            // not remote
            nResult := 0
    end case

return nResult

Jovan Bulajic
Belgrade, Yugoslavia

Mon, 25 Jan 1999 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Copy file from network drive to local drive?

2. Detecting Removable/Remote drives

3. Network Remote View Software

4. Using remote DAq on a network

5. fast remote VI control through network

6. Network setting in Remote Panel Control

7. win32net - How to connect to a remote network share from a service

8. Open/Check LabVIEW remote instance

9. Help: How to check if remote computer is running

10. Can't connect to library across mapped network drive

11. c5print.exe and c5printx.exe cannot run in the root directory of a network drive

12. Copy file from network drive?


Powered by phpBB® Forum Software