Results 1 to 3 of 3

Thread: Mapping Drive to PC

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    UK
    Posts
    49

    Cool Mapping Drive to PC

    I would like to map a drive withing a VB6 application.
    For example:

    Private Sub cmdONE_Click()

    'MAP A SERVER PATH TO THE I:/ DRIVE

    End Sub

    Private Sub CmdTWO_Click()

    'MAP ANOTHER SERVER TO DRIVE I:/

    End sub
    Qwerty007
    UK

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    www.mvps.org/vbnet have some great networking samples
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
    2.  
    3. 'Description
    4. 'Here \\vdk00005\proj is the name of the network path
    5. 'H: is the Drive Letter
    6. 'Map Network Drive (Connect)
    7. WNetAddConnection "\\vdk00005\proj", "", "H:"
    8.  
    9. Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
    10.  
    11. Private DisconnectIt As Long
    12.  
    13. 'Where H: is the drive letter you wish to connect
    14. 'The second parameter of this API determines whether to disconnect the drive if
    15. 'there are files open on it.   If it is passed FALSE, the disconnect will fail if there are open files
    16. 'If it is passed TRUE, the disconnect will occur no matter what is open on the drive
    17. DisconnectIt = WNetCancelConnection("H:", True)
    18. 'Map Network Drive (DisConnect)

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