Results 1 to 14 of 14

Thread: mapping a network drive

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    didn't decide yet
    Posts
    566

    mapping a network drive

    i have used the following code to map a network drive
    VB Code:
    1. Public Function m_mapDrive(LocalDrive As String, _
    2.   RemoteDrive As String, Optional UserName As String, _
    3.   Optional Password As String) As Boolean
    4.  
    5. 'Example:
    6. 'MapDrive "Q:", "\\RemoteMachine\RemoteDirectory", _
    7. '"MyLoginName", "MyPassword"
    8.  
    9.    Dim NetR As NETCONNECT
    10.  
    11.    NetR.dwScope = RESOURCE_GLOBALNET
    12.    NetR.dwType = RESOURCETYPE_DISK
    13.    NetR.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
    14.    NetR.dwUsage = RESOURCEUSAGE_CONNECTABLE
    15.    NetR.lpLocalName = Left$(LocalDrive, 1) & ":"
    16.    NetR.lpRemoteName = RemoteDrive
    17.  
    18.    m_mapDrive = (WNetAddConnection2(NetR, UserName, Password, _
    19.        CONNECT_UPDATE_PROFILE) = 0)
    20.    
    21.    
    22. End Function

    that code works ok if i use it in win2000 Os but when i tried in a win98 Os. I get the following:

    say i pass as a RemoteDrive drive the following path "\\machineName\dir1\dir2" i would expect to a new drive starting at dir2 (win2000 behaviour) but it maps a drive starting at dir1 which is the name of the shared directory of machineName
    is there a work around?

    thnks
    Come and get our ISDN CallerID http://www.3wm.biz

  2. #2
    Addicted Member Cyberius's Avatar
    Join Date
    Jan 2003
    Location
    Australia
    Posts
    145
    if both dir1 and dir2 are shared, or only dir1 is, try sharing only dir2....im guessing this gives win98 no option other than to share starting at dir2
    -=[Ç¥ßè®Ìú§]=-

    How many microsoft employees does it take to change a lightbulb? None, they simply define darkness as the new industry standard.

    CAUTION: OVERCLOCKING A 386 TO 5Ghz MAY BE HAZARDOUS

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    didn't decide yet
    Posts
    566
    dir2 is inside dir1 and that is working on win2000 it is supposed to work on win98 too or isn't?
    Come and get our ISDN CallerID http://www.3wm.biz

  4. #4
    Addicted Member Cyberius's Avatar
    Join Date
    Jan 2003
    Location
    Australia
    Posts
    145
    i dont know, i dont have a network to try it on, so i guess all you can do is try
    -=[Ç¥ßè®Ìú§]=-

    How many microsoft employees does it take to change a lightbulb? None, they simply define darkness as the new industry standard.

    CAUTION: OVERCLOCKING A 386 TO 5Ghz MAY BE HAZARDOUS

  5. #5
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    Here is a little bit different example how to connect or disconnect network drive. It uses windows connect and disconnect dialog boxes. See if you can use this
    VB Code:
    1. Private Declare Function WNetConnectionDialog Lib "mpr.dll" _
    2. (ByVal hwnd As Long, ByVal dwType As Long) As Long
    3. Private Declare Function WNetDisconnectDialog Lib "mpr.dll" (ByVal hwnd As Long, ByVal dwType As Long) As Long
    4.  
    5. Private Sub Command1_Click()
    6. 'Connect Network Drive
    7. xyz = WNetConnectionDialog(Me.hwnd, 1)
    8. End Sub
    9.  
    10. Private Sub Command2_Click()
    11. 'Disconnect Network Drive
    12. xyz = WNetDisconnectDialog(Me.hwnd, 1)
    13. End Sub

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    didn't decide yet
    Posts
    566
    even if u use these dialog boxes provide in win98 the results are the same that is if u want to map as a drive a path like \\machine\dir1\dir2 it only maps as a drive the \\machine\dir1 i suppose i m missing somthething but what?
    Come and get our ISDN CallerID http://www.3wm.biz

  7. #7
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    OK, I see now. When you map drive the syntax is

    \\machinename\sharename

    So if your folder dir2 not shared, there is no way you could map it directly

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    didn't decide yet
    Posts
    566
    but i will say it again in win2000 it can be done why?
    Come and get our ISDN CallerID http://www.3wm.biz

  9. #9
    Addicted Member PhilRob56's Avatar
    Join Date
    Oct 2002
    Location
    New York
    Posts
    249
    In this instance I would say that Win 2000 is incorrect. You can only map to a Shared Resource, so Win 98 is not in error here (surprise!).

    For example, if you want to map to Dir2, then Dir2 needs to be shared - a share within a share if you like.

    So....

    \\machinename\SharedDirectory1 = First available share
    \\machinename\Dir1\SharedDirectory2 = Second available share
    Some days you're the dog,
    and some days you're the hydrant.


    VB6 Enterprise

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    didn't decide yet
    Posts
    566
    what are u saying that is a win2000 bug?
    Come and get our ISDN CallerID http://www.3wm.biz

  11. #11
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    I'm not a network person, but I think it has something to do with NTFS. Win 2000 build on NT technology which is more secure than win 98.

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    didn't decide yet
    Posts
    566
    yes my Os is Win2000 on a h/d that is NTFS but the directories that i m trying to connect are on a FAT32 h/d
    Come and get our ISDN CallerID http://www.3wm.biz

  13. #13
    Fanatic Member
    Join Date
    Sep 2000
    Location
    Over There
    Posts
    522
    You can't map to directories inside of a shared directory.
    you'll have to share the other folder and map directly to it.
    It Never Fails. Everytime I try to make a program idiot proof, the world makes a better idiot.

  14. #14
    Addicted Member PhilRob56's Avatar
    Join Date
    Oct 2002
    Location
    New York
    Posts
    249
    Originally posted by Dalceon
    You can't map to directories inside of a shared directory.
    you'll have to share the other folder and map directly to it.
    Correct.

    If you want to map to both Dir1 and Dir2 then they both must be independantly Shared.

    Dir1 = Share1
    Dir2 = Share2

    then:

    Q: = \\machinename\Share1
    R: = \\machinename\Share2
    Some days you're the dog,
    and some days you're the hydrant.


    VB6 Enterprise

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