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

x
?
Solved

Map a network drive in VB5

Posted on 1998-11-30
2
Medium Priority
?
296 Views
Last Modified: 2010-05-03
I need to map a network drive in a VB5 program.  After I use the files from the drive, I then need to delete the mapping the program created.  Any thoughts?
0
Comment
Question by:roberta_pape
[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
2 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1447487
You can launch the utility "MAP" with the correct parameters.
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 200 total points
ID: 1447488
http://www.zdnet.com/wsources/content/960216/pb.html

Window of Opportunity

Things are looking up for Win 95, which has a variety of built-in API functions for accessing network services. These let you display the standard Win 95 dialogs for connecting or disconnecting network drives, obtain the user's log-on name, etc., and they are fairly easy to call from Visual Basic 4.0. (Use the VB 4.0 API Assistant to obtain declarations for the functions and data types I use below.) For instance, the following code obtains the user's log-on name from Win 95 and displays it in a message box:


    Dim i&, uName As String * 128
    i& = WNetGetUser(0&, uName, 127)
    MsgBox uName



Connecting to drives is also easy. You can call up the standard Map Network Drive dialog with this single line of code:


    i& = WNetConnectionDialog(hwnd, 1)



Alternatively, your program could use the following code to skip the dialog box and map a network drive called \\PB'S WFW\WFW_D to logical drive J:.


    Const netdrive =1
    uName$="", Pass$=""
    Dim nr As NETRESOURCE
    nr.dwType = netdrive
    nr.lpLocalName = "J:"
    nr.lpRemoteName = "\\PB'S WFW\WFW_D"
    i& = WNetAddConnection2(nr, uName$, Pass$, 0)



You still need a network services component to perform more advanced network operations, but there hasn't been much progress in this area. For instance, NetPak Professional, from the Crescent division of Progress Software, offers access to a comprehensive collection of NetWare functions but doesn't do enough to simplify their use. Using NetPak's 16- or 32-bit OCX, it would still take about ten lines of code to fill an array with the names of all the groups to which a user belongs.

The best thing about NetPak is its collection of demo code that illustrates how the OCX performs standard network-management tasks. And it doesn't require much effort to massage that code into a module full of high-level methods that would keep you from making low-level NetWare calls. Better yet, you could put them all in a Class module and build yourself a network services OLE automation server with a nice class hierarchy to call from any OLE automation client.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 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