Prev: Shellexecute in VB6
Next: Help with trim!
From: VideoNut on 27 Feb 2006 10:38 Because I am using a USB network adapter sometimes when my XP machine boots up the device is not ready when XP attempts top map the server drive. The icon on my computer has a red X across it. I tried to write a VB6 program that will keep trying to connect using the "WNetAddConnection2" command. Unfortunately it does not work unless I disconnect the drive (i.e. completely remove it) which I would prefer not doing. Is there a command to "reconnect" a drive that is mapped but "not ready"
From: Randy Birch on 27 Feb 2006 21:23 You can use the code at http://vbnet.mvps.org/code/network/isnetdrive.htm to determine whether net drives have been reconnected after booting up. For those drives that return 2 from this code, call WNetRestoreConnection ... Option Explicit Private Declare Function WNetRestoreConnection Lib "mpr.dll" _ Alias "WNetRestoreConnectionW" _ (ByVal hwndParent As Long, _ ByVal lpDevice As Long) As Long Private Sub Command1_Click() Call WNetRestoreConnection(Me.hWnd, StrPtr("Y:")) End Sub -- Randy Birch MS MVP Visual Basic http://vbnet.mvps.org/ Please reply to the newsgroups so all can participate. <VideoNut(a)aol.com> wrote in message news:q7760255hggtv1i17bjtouch9kr2hldmpq(a)4ax.com... Because I am using a USB network adapter sometimes when my XP machine boots up the device is not ready when XP attempts top map the server drive. The icon on my computer has a red X across it. I tried to write a VB6 program that will keep trying to connect using the "WNetAddConnection2" command. Unfortunately it does not work unless I disconnect the drive (i.e. completely remove it) which I would prefer not doing. Is there a command to "reconnect" a drive that is mapped but "not ready"
From: VideoNut on 28 Feb 2006 04:47 Thanks Randy..It was what I was looking for. One last question. Is there a way to supress the pop-up if it is unable to reconnect the drive. I googled WNetRestoreConnection and could not find dicumnetation on it On Mon, 27 Feb 2006 21:23:37 -0500, "Randy Birch" <rgb_removethis(a)mvps.org> wrote: >You can use the code at http://vbnet.mvps.org/code/network/isnetdrive.htm to >determine whether net drives have been reconnected after booting up. For >those drives that return 2 from this code, call WNetRestoreConnection ... > >Option Explicit > >Private Declare Function WNetRestoreConnection Lib "mpr.dll" _ > Alias "WNetRestoreConnectionW" _ > (ByVal hwndParent As Long, _ > ByVal lpDevice As Long) As Long > > >Private Sub Command1_Click() > > Call WNetRestoreConnection(Me.hWnd, StrPtr("Y:")) > >End Sub
From: Randy Birch on 28 Feb 2006 21:08 > is there a way to suppress the pop-up if it is unable to reconnect the > drive. No, not that I can see. >I googled WNetRestoreConnection and could not find >documentation on it WNetRestoreConnection is one of the APIs that Microsoft was required to publish as part of its settlement with the U.S. Department of Justice. Microsoft notes that while WNetRestoreConnection is available in Microsoft Windows 2000 and Windows XP, "it may be altered or unavailable in subsequent Windows versions". I'd bet it won't be. -- Randy Birch MS MVP Visual Basic http://vbnet.mvps.org/ Please reply to the newsgroups so all can participate.
|
Pages: 1 Prev: Shellexecute in VB6 Next: Help with trim! |