Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Connected to Network
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00144975
Message ID:
00145416
Views:
34
>>>Anybody know a reliable way to determine if a workstation is connected to a network?
>>>
>>>Greg
>>
>>In VFP 6.0, there's the DRIVETYPE() function. If you're using VFP 5.0, the foxtools library has this function.
>>
>>hth,
>
>I looked at that but I may not know what drives are mapped. I guess I could get a list of them and start looping thru it.
>
>I'm looking at WNetEnumResource and trapping the error. My reply to Ed explains what I'm trying to do. Sound reasonable?
>
Hi Greg,

At the end of this message, I'll show you how to get a list of mapped drives via the API.

As far as WNetEnumResource, it will give you what you're looking for. It may, however, be more practical just to get the networks that have already been mapped to. When you call WNetOpenEnum, use RESOURCE_GLOBALNET as the scope parameter and RESOURCETYPE_DISK as the type. I wrote an article in the May, 1998 issue of FoxPro Advisor on the various problems in dealing with WANs. Include in the article was the code necessary to do what you're looking for. There was one difference, I used the function to return the list of "remembered" servers via RESOURCE_REMEMBERED. If you need more help, just post.

Now the drives, there are two functions you need to look at: GetLogicalDrives and GetLogicalDriveStrings. Here's some sample code as to how I'd deal with them.
* GetLogicalDrives sample
DECLARE INTEGER GetLogicalDrives IN Win32API
lndrives = GetLogicalDrives()
FOR lni = 0 TO 25
  IF BITTEST(lndrives, lni)
    * The drive is in use
    lcdrive = CHR(65 + lni) + ":"
  ENDIF
NEXT
* GetLogicalDriveStrings
DECLARE INTEGER GetLogicalDriveStrings IN Win32API;
  INTEGER lnbufferlength, STRING @lcbuffer
lcbuffer = SPACE(105)
lnresult = GetLogicalDriveStrings(105, @lcbuffer)
lcbuffer = LEFT(lcbuffer, lnresult)
lndrives = OCCURS(CHR(0), lcbuffer)
lnstart = 1
FOR lni = 1 TO lndrives
  ? SUBSTR(lcbuffer, lnstart, 3)
  lnstart = AT(CHR(0), lcbuffer, lni) + 1
NEXT
hth,
George

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

Click here to load this message in the networking platform