Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting a Network in Win NT4.0
Message
 
To
04/11/1997 14:41:11
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00058197
Message ID:
00058228
Views:
28
>I have a FoxProw 2.6 application I am converting to VFP 5.0.
>FoxProw 2.6 application runs under Win 3.11 or Win 95 on Novell.
>
>The FoxProw 2.6 application allows people to "check out" files to
>work on on their laptops.
>
>Rather than have two different applications, one for running on the
>'network' and one to run on 'local' (laptop) computers I have the
>application determine if there is a network attached to the computer.
>
>In the FoxProw 2.6 application the following has always worked:
>
>glNetwork = adir("aadir","f:\*.*","D") > 0
>
>In otherwords if there are one or more files or directories
>on the f: drive (the SYS drive) then there is a network there.
>
>When I converted to VFP 5.0 I used the directory() function to
>do the same thing.
>
>glNetwork = directory("\\HWI\SYS")
>
>This worked fine in Win 95. However, now I have laptops running
>Win NT4.0.
>
>In Win NT4.0 the above directory() statement causes a Win NT4.0
>error message:
>
>"There is no disk in the drive. Please insert a disk into
>'\Device\RemPartion5' "
>
>What do I need to do to supress the above message in Win NT4.0? Or
>does anyone have a cleverer solution for detecting a network?

Don,

You could probably do something like this:

FUNCTION Is_Net

DECLARE INTEGER GetLogicalDrives IN Win32API
DECLARE INTEGER GetDriveType IN Win32API;
STRING lcdrive
LOCAL lndrivemap, llresult, lni, lcdrive, lndrivetype
lndrivemap = GetLogicalDrives()
llresult = .F.
* Start with D:
lni = 2
DO WHILE lni < 31 AND NOT llresult
lni = lni + 1
IF BITTEST(lndrivemap, lni)
lcdrive = CHR(65 + lni) + ":\:
lndrivetype = GetDriveType(lcdrive)
llresult = (lndrivetype = 4)
ENDIF
ENDDO
RETURN llresult

That will tell you whether or not a net is present without generating any error messages. Side note, FOXTOOLS has a function called DriveType that's a hook into GetDriveType. You pass it the same parameters and it returns the same values.

hth,

George
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform