No announcement yet.

Mapped network drive info

  • Filter
  • Time
  • Show
Clear All
new posts

  • Mapped network drive info

    I need to know if a specific disk is a network drive mapped disk and the mapped path.
    if G: is mapped to \\MyServer\MyPath
    I need to get info that G: is a networked mapped disk
    and is mapped to \\MyServer\MyPath

    Does someone know how to?

    Thanks a lot

    mailto:[email protected][email protected]</A>

  • #2
    Here is a function I created to list all drive mappings. You should
    be able to have it choose the drive letter easy enough. Or you could
    use GetLogicalDrives() and then check each drive letter with GetDriveType("C:\")
    to see if it is %DRIVE_REMOTE (network drive). Then use part of my code
    below to get the network path.

    Hope this helps.

    '  Returns a tab delimited string of all drive mappings
    Function AllMappings() AS String
       Local iCount      AS Long
       Local dRet        AS Dword
       Local sText       AS String
       Local dCount      AS Dword
       Local dSize       AS Dword
       Local hEnum       AS Dword
       Dim NR(0 To 50)   AS NETRESOURCE
       NR(0).dwScope = %RESOURCE_CONNECTED
       dRet = WNetOpenEnum(%RESOURCE_CONNECTED, %RESOURCETYPE_DISK, ByVal 0, NR(0), hEnum)
       If dRet = %NO_ERROR Then
             dCount = 50
             dSize  = SizeOf(NETRESOURCE) * dCount
             dRet = WNetEnumResource(hEnum, dCount, NR(0), dSize)
             For iCount = 0 To dCount - 1
                If NR(0).lpLocalName <> 0 And Len(NR(iCount)[email protected]) <> 0 Then 'local device maps only
                   sText = sText + NR(iCount)[email protected] + "=" + NR(iCount)[email protected] + $TAB
                End If
             Next iCount
          Loop While dRet = %NO_ERROR
       End If
       Call WNetCloseEnum(hEnum)
       If len(sText) > 1 Then Function = Left$(sText,Len(sText)-1) 'remove the last $Tab
    End Function
    "I haven't lost my mind... its backed up on tape... I think??"

    [This message has been edited by William Burns (edited August 03, 2004).]
    "I haven't lost my mind... its backed up on tape... I think??" :D