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
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
|