Solved

Map a network drive in VB5

Posted on 1998-11-30
2
245 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
  • 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 100 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 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