Getting UNC Network Path Name 
Author Message
 Getting UNC Network Path Name

Hello,

I've found an article in the Knowledge Base on getting the Network Path
UNC using the mpr.dll and the WNetGetConnectionA function. Its for V7 of
Access though and I can't get it to work with V2 I keep getting error
loading DLL even though I've actually found the dll and seen the
function name in it! Exactly what syntax should I use for V2?

Does anyone know how to get the UNC's either by the above method or
otherwise?

Cheers.

Andy Mills.



Sun, 19 Sep 1999 03:00:00 GMT  
 Getting UNC Network Path Name

: I've found an article in the Knowledge Base on getting the Network
: Path UNC using the mpr.dll and the WNetGetConnectionA function. Its
: for V7 of Access though and I can't get it to work with V2 I keep
: getting error loading DLL even though I've actually found the dll
: and seen the function name in it! Exactly what syntax should I use
: for V2? Does anyone know how to get the UNC's either by the above
: method or otherwise?
:...............................................

Hi Andy,

Declare Function WNetGetConnection Lib "User" (ByVal lpszLocalName As
String, ByVal lpszRemoteName As String, cbRemoteName As Integer) As
Integer

Following is the modified code required to get the UNC path.

Example usage:  ? GetUNCPath ("l:")

-- Chris Bell --

 ' These represent the possible returns errors from API.
Const ERROR_BAD_DEVICE = 1200
Const ERROR_CONNECTION_UNAVAIL = 1201
Const ERROR_EXTENDED_ERROR = 1208
Const ERROR_MORE_DATA = 234
Const ERROR_NOT_SUPPORTED = 50
Const ERROR_NO_NET_OR_BAD_PATH = 1203
Const ERROR_NO_NETWORK = 1222
Const ERROR_NOT_CONNECTED = 2250
Const NO_ERROR = 0

 Function GetUNCPath (strDriveLetter As String) As String
 On Local Error GoTo GetUNCPath_Err
 Dim Msg As String, varReturn As Variant
 Dim lpszLocalName As String
 Dim lpszRemoteName As String
 Dim cbRemoteName As Integer
 lpszLocalName = strDriveLetter
 lpszRemoteName = String$(255, Chr$(32))
 cbRemoteName = Len(lpszRemoteName)
 varReturn = WNetGetConnection(lpszLocalName, lpszRemoteName,
cbRemoteName)
 Select Case lngReturn
 Case ERROR_BAD_DEVICE
    Msg = "Error: Bad Device"
 Case ERROR_CONNECTION_UNAVAIL
    Msg = "Error: Connection Un-Available"
 Case ERROR_EXTENDED_ERROR
    Msg = "Error: Extended Error"
 Case ERROR_MORE_DATA
    Msg = "Error: More Data"
 Case ERROR_NOT_SUPPORTED
    Msg = "Error: Feature not Supported"
 Case ERROR_NO_NET_OR_BAD_PATH
    Msg = "Error: No Network Available or Bad Path"
 Case ERROR_NO_NETWORK
    Msg = "Error: No Network Available"
 Case ERROR_NOT_CONNECTED
    Msg = "Error: Not Connected"
 Case NO_ERROR
    ' all is successful...
 End Select
 If Len(Msg) Then
    MsgBox Msg
 Else
    ' Display the path in a Message box or return
    ' the UNC through the function.
    MsgBox Left$(lpszRemoteName, cbRemoteName)
    GetUNCPath = Left$(lpszRemoteName, cbRemoteName)
 End If
GetUNCPath_End:
    Exit Function
GetUNCPath_Err:
    MsgBox Error
    Resume GetUNCPath_End
End Function

-- end of message --



Mon, 20 Sep 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. UNC Name Need to code a network Path

2. Getting UNC Network name in Access V2

3. Determining the UNC path from a mapped network drive

4. Getting UNC path using drive letter

5. VB5: Getting a drive letter from UNC paths

6. unc path / ip address / internet name ???

7. returning full physical path name of a remote UNC share

8. UNC Path Names

9. How to get UNC path names?

10. How to get UNC path names?

11. HOWTO: Browse for UNC name of a computer in your Network

12. VB UNC names for Network Drives

 

 
Powered by phpBB® Forum Software