Converting network drive-based path to universal path name

'The following code shows how to use the WNetGetUniversalName for converting
'network drive-based path (Like I:\windows) to universal path name (Like \\MyComputer\c\windows)
'
Private Declare Function WNetGetUniversalName Lib "mpr" Alias "WNetGetUniversalNameA" _
(ByVal lpLocalPath As String, ByVal dwInfoLevel As Long, lpBuffer As Any, lpBufferSize As Long) As Long

Private Const UNIVERSAL_NAME_INFO_LEVEL = 1
Private Const REMOTE_NAME_INFO_LEVEL = 2
Private Const UNIVERSAL_NAME_BUFFER_SIZE = 1000
Private Const NO_ERROR = 0

Private Type UNIVERSAL_NAME_INFO
    lpUniversalName                         As Long
    buf(UNIVERSAL_NAME_BUFFER_SIZE - 4)     As Byte
End Type

Private Sub cmdGetUniversal_Click()
    Dim BufSize         As Long
    Dim uni             As UNIVERSAL_NAME_INFO
    
    BufSize = UNIVERSAL_NAME_BUFFER_SIZE
    If WNetGetUniversalName(txtPath.Text, UNIVERSAL_NAME_INFO_LEVEL, uni, BufSize) = NO_ERROR Then
        'After we return from WNetGetUniversalName, the lpUniversalName contains a pointer for the 
	'universal path name.
        'The pointer is usually points to the first byte of the buffer array 
	'(buf variable in UNIVERSAL_NAME_INFO ).
        
	'Just to be safe, I calculate the exact location of the string in the buffer, 
	'by the following expression: (The result is always 1)
        StartLoc = uni.lpUniversalName - VarPtr(uni) - 3
        txtUniversal.Text = Mid$(StrConv(uni.buf, vbUnicode), StartLoc)
    Else
        MsgBox "Error: cannot find the universal path of " & txtPath.Text, vbOKOnly Or vbExclamation, ""
    End If
    
End Sub


Download this sample project