
How to convert path to UNC path?
Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA"
(ByVal lpszLocalName As String, ByVal lpszRemoteName As String,
cbRemoteName As Long) As Long
'Network messages
Const NO_ERROR = 0
Const ERROR_NOT_CONNECTED = 2250&
Const WN_SUCCESS = NO_ERROR
Const WN_NOT_CONNECTED = ERROR_NOT_CONNECTED
Public Function GetUNCName(sDrive As String) As String
'sDrive - the drive letter
'Returns a UNC name for the drive; returns empty string if not
'connected or the error code
Dim Ret As Long
Dim sUNCName As String
sUNCName = Space$(50)
'Need to make sure there is a colon
If Len(sDrive) = 1 Then
sDrive = sDrive & ":"
End If
Ret = WNetGetConnection(LCase$(sDrive), sUNCName, Len(sUNCName))
Select Case Ret
Case WN_SUCCESS
GetUNCName = sUNCName
Case WN_NOT_CONNECTED
GetUNCName = ""
Case Else
GetUNCName = "Net ERROR#: " & Str$(Ret)
End Select
End Function
Quote:
>Hi:
>I need to be able to convert a regular path to the UNC version (g:\windows
>to \\servername\sharename\windows, for example). This is necessary because
>I have a multiuser jet database with attached tables. If the path of the
>attached tables doesn't resolve for all users then the attachment doesn't
>work.
>If there is not a way to convert path names then I could get by with
>creating the permanently mapped share myself so long as I can determine the
>UNC path name. I'm working with VB5 on Win95/NT4. I would appreciate any
>advice you can offer.
>Regards,
>Kyle Reed
http://www.geocities.com/SiliconValley/Park/1178