Solved

Map a network drive in VB5

Posted on 1998-11-30
2
216 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
Comment Utility
You can launch the utility "MAP" with the correct parameters.
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 100 total points
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now