CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Mapping a drive

  1. #1
    Join Date
    Jan 2000
    Posts
    16

    Mapping a drive

    Could someone write some code that maps a network drive. This is tricky part. Write it as sammal as you can, no error control even. I'm trying to learn it starting simple. Thanks for any help


  2. #2
    Join Date
    Feb 2000
    Location
    Indiana
    Posts
    308

    Re: Mapping a drive

    You need to use the WNetAddConnection function for this.

    'Declare the API call
    Declare Function WNetAddConnection Lib "mpr.dll" Alias _
    "WNetAddConnectionA" (byval lpszNetPath as string, _
    byval lpszPassword as string, byval lpszLocalName _
    as string) as Long

    'Now We can use it somewhere
    sShare = "//MyServer/MyShare"
    sPwd = vbNullString
    sDriveLetter = "X:"

    lngResult = WNetAddConnection(sShare, sPwd, sDriveLetter)





  3. #3
    Join Date
    Jan 2000
    Posts
    16

    Re: Mapping a drive

    I'm not sure where to put all the code. do i put all of it in a new module. what part do i put in a command button


  4. #4
    Join Date
    Feb 2000
    Location
    Indiana
    Posts
    308

    Re: Mapping a drive

    Put the Declare statement in a standard module (be sure to place the keyword Public before it). Declares can only be placed in standard modules. The other code you can put wherever you like (e.g. Command1_Click()).


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured