How to convert path to UNC path? 
Author Message
 How to convert path to UNC path?

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



Fri, 24 Dec 1999 03:00:00 GMT  
 How to convert path to UNC path?

You can call the Win32 API function WNetGetConnection.  You pass it a drive
letter and it will return the UNC information.

Here's the function declaration:

Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA"
(ByVal lpszLocalName As String, ByVal lpszRemoteName As String,
cbRemoteName As Long) As Long

Hope this helps.

John Halsey, MCSE
MicroAge - Portlan
d, OR

 Kyle Reed wrote in

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



Sun, 26 Dec 1999 03:00:00 GMT  
 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


Mon, 27 Dec 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Converting logical paths to UNC paths

2. Help converting UNC paths to physical paths.

3. Converting logical paths to UNC paths

4. How to convert local path to UNC-path?

5. How to convert local path to UNC-path?

6. Local path vs UNC Path

7. How transform path into unc-path ?

8. turning a local path into a UNC path

9. How to convert file path to UNC?

10. Convert Path to UNC

11. Convert path to UNC

12. Converting a path to its UNC equivalent?

 

 
Powered by phpBB® Forum Software