Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detect Presence of Network
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01249575
Message ID:
01249659
Views:
19
>I was wondering if there is a better way for detecting the presence of the LAN (Local Area Network)?
>
>The following is what I am using right now to detect whether or not a certain drive letter, folder and subfolder exist.
>
>
>* Detect the presence of the network.
>IF DIRECTORY("E:\MSDS\DATA")
>  oApp.NetworkPresent=.T.
>ELSE
>   oApp.NetworkPresent=.F.
>ENDIF
>
That should work fine for your stated purpose. Some comments:
You could try one of the following instead:
IF DIRECTORY( "\\ServerName\ShareName\Folder\" )
* will work if the local machine has lost its E: drive mapping. In that case
* you can use WinAPI calls to re-establish the mapped drive E:
* Or, you can change your app to use these UNC-style identifiers instead of mapped drives

* Even more "reliable" is
IF DIRECTORY( "\\192.168.xxx.xxx\ShareName\Folder\" )
* Since you're specifying a fixed IP address this should work
* even if there are NetBIOS or DNS problems (e.g. DNS configuration, Browse Master, WINS) on your network
* If this works where checking a drive letter does not, it's useful information
* for network troubleshooting
Another comment about the drive letter E: you've chosen:

- most computers these days have a C: hard drive and a D: optical drive
- therefore, nominally the next available drive letter is E:

However, if you do this it can cause problems with USB memory sticks or hard drives the user may want to attach to the workstation. When they do so the stick or HD will by default be mapped as drive E:, which will then be inaccessible because a network drive mapping has already overridden it.

For this reason it's better to start mapped network drives further down the alphabet, leaving some space for more local devices. Some admins start network drive mappings at Z: and work backwards from there.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform