[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

Map a network drive in VB5

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
roberta_pape
Asked:
roberta_pape
  • 2
1 Solution
 
MirkwoodCommented:
You can launch the utility "MAP" with the correct parameters.
0
 
MirkwoodCommented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now