
How to convert file path to UNC?
Quote:
>How do I convert a file path to UNC. For example, how do I convert
>c:\program files\x.txt to \\robertg\c\Program Files\x.txt.
>Is there a Win api that does that?
Using the WNetGetConnection, you can get the UNC(?) path of the drive
mapping. Here's a sample in Win-16, that prints the mapping when
selecting a different drive in a drive list box:
Declare Function WNetGetConnection% Lib "User" (ByVal lpLocalName$,
ByVal lpRemoteName$, RemoteNameSize%)
Declare Function GetDriveType% Lib "Kernel" (ByVal nDrive%)
Sub Drive1_Click ()
Dim driveName As String * 256, ret%, length%
length = Len(driveName) - 1
ret = WNetGetConnection(Left$(drive1, InStr(drive1 & ":", ":")),
driveName$, length)
length = InStr(driveName & Chr$(0), Chr$(0)) - 1
label2 = drive1 & " " & "Return code = " & CStr(ret) & " , Len = " &
CStr(length)
label1 = Chr$(34) & Left$(driveName, length) & Chr$(34)
End Sub
HTH,
Bart.