Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    357
    Thanks
    0
    Thanked 0 Times in 0 Posts

    UNC Path & Mapped drive (Access 97 SR2)

    Hi Everyone!

    I'm trying to find code (an api call?) that will tell you where a unc path is mapped to.

    I was able to find the api call that tells you what is the unc path of a mapped drive, but I'm looking for exactly the opposite (since the user could easily map a path to a different drive letter).

    Does anyone know where I can find such a thing? I've been looking through allapi.net, but haven't seen this (or at least couldn't recognize it).

    Any hints would be greatly appreciated.

    Thanks!

    Cecilia :-)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: UNC Path & Mapped drive (Access 97 SR2)

    I'm sure somebody will come up with a better idea, but here is a brute force approach.

    You might loop through all drive letters, get the UNC path from it and compare it to "your" UNC path. If you get a match, you know the drive letter and you can exit from the loop. Be sure to convert everything to upper case before comparing.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    357
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: UNC Path & Mapped drive (Access 97 SR2)

    Urrrrgh. I hadn't thought of that, but....

    We have every drive letter mapped and then some. But that's not really the problem, part of it is that if you do a lot of travelling, or cross-divisional work (like I do), you might have drives mapped that are 3,000 miles away across a 28.8b (or less) Wan. I'll try it, but I'm worried that between the number of drives mapped and the potential for getting bogged down on the Wan, it'll be really slow.

    I'm hoping there's a neater way to do it.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: UNC Path & Mapped drive (Access 97 SR2)

    A UNC path is to network location and eliminates the need for a drive map. Drive mappings depend on the specific domain and can vary between machines. I don't see how you would ever know how drives were mapped except from the current workstation. What are you actually trying to accomplish with this?
    Charlotte

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    357
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: UNC Path & Mapped drive (Access 97 SR2)

    Hi Charlotte--

    I think I was going overboard with helping out the users. The problem is that some of us map our drives to different letters because we move around between regions and divisions. But most don't, and don't know how, and don't even what a UNC path is. So in order for things to go correctly, I need to use the unc path, but a user wouldn't know what that is, they'd think it was jibberish. So I wanted to return to the user the equivalent of where things were being saved, in a manner that he'd understand.

    Instead of going through all that, I'll probably just tell some "superusers" how to do it and let the others go to them for help changing drive paths.

    Cecilia :-)

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,896
    Thanks
    0
    Thanked 86 Times in 82 Posts

    Re: UNC Path & Mapped drive (Access 97 SR2)

    Hi Cecilia,
    This may be a bit late but I came across the WNetGetConnection API this morning and had a vague recollection that someone here had been looking for something like it. I think it should do exactly what you were after.
    Hope that helps.
    Regards,
    Rory
    Microsoft MVP - Excel.

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    357
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: UNC Path & Mapped drive (Access 97 SR2)

    Hi Rory!

    LOL, yeah, that project is so far off my desk, I'm not going back....but I'm the same way, a problem is something that _just_ has to be solved.

    I think that is the API call that I use to get the unc path of a mapped drive. But I was trying to do the opposite: get the mapped drive name of a unc path. Is there a way to do that with this call?

    Please don't spend any time or effort on this, because I won't use it, but it would be interesting to know....

    Cecilia :-)

  8. #8
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,326
    Thanks
    1
    Thanked 12 Times in 12 Posts

    Re: UNC Path & Mapped drive (Access 97 SR2)

    You wrote:
    I think that is the API call that I use to get the unc path of a mapped drive. But I was trying to do the opposite: get the mapped drive name of a unc path. Is there a way to do that with this call?

    I doubt there is such a thing. This would seemingly imply that there was something fixed about a specific mapping. Since every system could be mapped differently, and since any particular UNC you have might not be mapped at all on a particular PC, the only way to get this is to examine each drive letter yourself.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  9. #9
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: UNC Path & Mapped drive (Access 97 SR2)

    If using VB/VBA 6.0 or later you can use File System Object to get mapped network drive for a specified UNC path. You have to set a reference to Microsoft Scripting Runtime library (SCRRUN.DLL). Sample code:

    Sub GetMappedDrive(strUNCPath As String)

    Dim fso As Scripting.FileSystemObject
    Dim D As Scripting.Drive
    Dim bFound As Boolean
    Dim strMsg As String

    bFound = False
    Set fso = CreateObject("scripting.filesystemobject")
    For Each D In fso.Drives
    If D.ShareName = strUNCPath Then
    strMsg = "The mapped network drive for UNC path " & strUNCPath & " is " & D.DriveLetter & ":"
    MsgBox strMsg, vbInformation, "MAPPED DRIVE FOUND"
    bFound = True
    End If
    Next D

    If bFound = False Then
    strMsg = "Mapped drive for UNC path " & strUNCPath & " not found."
    MsgBox strMsg, vbInformation, "MAPPED DRIVE NOT FOUND"
    End If

    Set D = Nothing
    Set fso = Nothing

    End Sub

    You can also do the opposite, get UNC path for mapped drive using the Drive object's ShareName property.

    HTH

  10. #10
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    357
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: UNC Path & Mapped drive (Access 97 SR2)

    Cool! Now I need a new place to use it :-)

    Thanks for your help :-)

  11. #11
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    357
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Network Path ***Need new solution

    Ugggh, I am back to needing to do this again. Unfortunately, now that we're in XP, this code doesn't work (not quite sure why yet). When I try to run it with my network path, it returns the same network path.

    Access 2002, WinXP (for better or worse....)

    Just to set it up again, I have a program that saves documents in a location that the user specifies. When it opens, it opens defaulted to their My Documents folder--Which under XP, is a network path. The users get all scared when they see the network path, since they just want to save it to C:My Documents (or their shared drive, which is s:foldername, which also shows up as a funky network path).

    I need to convert the network path to the drive path. It doesn't matter if everyone has different drive mappings, because it is only good for saving one document. But I want to convert s112reg3456username$My Documents to simply c:My Documents.

    Does anyone know a way to do this?

    TIA!

    Cecilia :-)

Posting Permissions

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