Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to force reconnection of a network mapped drive?
Message
 
To
21/10/2002 15:42:22
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00713586
Message ID:
00713642
Views:
18
This message has been marked as a message which has helped to the initial question of the thread.
>Hi, George!
>
>>>I'd like to show the drive in GETDIR(), by forcing the connection (if possible). If the drive really isn't available, then of course, it shouldn't show.
>>>
>>
>>Um, a SWAG. Look at WNetRestoreConnectionW() in the networking SDK.
>
>Hm. I don't find a hit "WNetRestoreConnectionW" in MSDN, and no sign of it in the topic ms-help://MS.MSDNQTR.2002JUL.1033/wnet/networks_0u43.htm. Ah, Google comes thru. I get a hit on the MS site http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetrestoreconnectionw.asp. It does look great, except for the bit where they say it may be subsequently unavailable. It's okay if its only W2K and up, but going to be a drag if it doesn't continue past XP. Might be why they've taken it out of the distributed MSDN library. Too bad.
>
>You're still one of the two API gods. :)

Thank you, kind lady. It's in there (at least the October, 2002 issue). I found it in the network functions overview, and I must say I'm surprised that a search didn't turn it up.

>
>>Don't know if VFP's DRIVETYPE() function returns a zero or not here if the drive is attached but not available. The function is only available on Win2K/XP and is used in restoring persistent connections defined by the user, so I'm not sure that this is going to do the job for you.
>
>I think at this point I'll drop back and punt, AKA KISS, and just iterate thru the possible drive letters and ping 'em. I think that pretty much anything will do that touches the drive.
>
>Thanks!

You're welcome, but let me make another suggestion. Is the WSH available? If so, I'd use it to enumerate the network drives
oNet = CREATEOBJECT('WScript.Network')
oDrives = oNet.EnumNetworkDrives
? oDrives.Count
? oDrives.Item(0)
The drive letters are in the even numbered Items (0, 2, etc.). I don't know if the Scripting.FileSystemObject's GetDrive method may be of help as well via its IsReady property.
George

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

Click here to load this message in the networking platform