Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How Do You Map Network Drives in VB?

Posted on 1998-08-20
3
Medium Priority
?
206 Views
Last Modified: 2010-04-30
How do you map and disconnect network drives in VB?

The following code doesn't seem to work:

#If Win32 Then
     Declare Function WNetConnectionDialog Lib "mpr.dll" (ByVal hWnd As Long, ByVal dwType As Long) As Long
     Declare Function WNetDisconnectDialog Lib "mpr.dll" (ByVal hWnd As Long, ByVal dwType As Long) As Long
#End If
 
Private Sub netdrivebutton_Click(Index As Integer)
     Dim i As Long
     Select Case Index
     Case 0  'Map To is Selected
         #If Win32 Then
             i = WNetConnectionDialog(Me.hWnd, RESOURCETYPE_DISK)
             If i <> 0 And i <> -1 And i <> 1223 Then
                 MsgBox "Error: " & i, 48, 1
             End If
         #End If
     Case 1  'Disconnect is Selected
         #If Win32 Then
             i = WNetDisconnectDialog(Me.hWnd, RESOURCETYPE_DISK)
         #End If
     End Select
End Sub
0
Comment
Question by:darren100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
KEWL earned 20 total points
ID: 1430086
Sub MapDrive(Drv as string, Tgt as string)
shell ("NET USE " & drv & " " & tgt,0
End sub

Sub UnMap(Drv as string)
shell ("NET USE " & drv & " /delete"),0
end sub

These subs use the dos program NET that comes with w95/98.
it isnt very technical but it gets the job done
0
 
LVL 14

Expert Comment

by:waty
ID: 1430087
I have given you complete VB code in the following question :

http://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10073988

It uses API, no shell to extern app and works very well.
0
 
LVL 1

Expert Comment

by:KEWL
ID: 1430088
although i want the points, waty's API would be a better choice
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question