Solved

Map a network drive in VB5

Posted on 1998-11-30
2
277 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 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

705 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