Interesting... I figured VB6 was just doing a simple GetVolumeInformation call, because it was missing the label in all the same circumsances... you actually have to do a little work to get the network path like that; not sure why VB would do it separately. Maybe there's a 3rd way that does that too?
Anyway could you see if this returns the share path:
LPWStrToStr is already in the project; if that crashes in the above, switch to the alternate PointerToStringW; I don't know how it allocates the string and don't have a network drive handy to check.Code:Private Type UNIVERSAL_NAME_INFOW lpUniversalName As LongPtr End Type Private Enum NETWK_NAME_INFOLEVEL UNIVERSAL_NAME_INFO_LEVEL = &H00000001 REMOTE_NAME_INFO_LEVEL = &H00000002 End Enum Private Declare PtrSafe Function WNetGetUniversalNameW Lib "mpr.dll" (ByVal lpLocalPath As LongPtr, ByVal dwInfoLevel As NETWK_NAME_INFOLEVEL, lpBuffer As Any, lpBufferSize As Long) As Long Private Declare PtrSafe Function lstrlenW Lib "kernel32" (lpString As Any) As Long Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As LongPtr) Private Sub checkname() Dim tn As UNIVERSAL_NAME_INFOW Dim lRet As Long lRet = WNetGetUniversalNameW(StrPtr("L:\"), UNIVERSAL_NAME_INFO_LEVEL, tn, LenB(tn)) If lRet = 0 Then Dim sPath As String sPath = LPWSTRtoStr(tn.lpUniversalName) Debug.Print sPath End If End Sub Private Function PointerToStringW(ByVal lpStringW As Long, Optional Length As Long = -1) As String Dim Buffer() As Byte If lpStringW Then If Length < 0 Then Length = lstrlenW(lpStringW) * 2 If Length Then ReDim Buffer(0 To (Length - 1)) As Byte CopyMemory Buffer(0), ByVal lpStringW, Length PointerToStringW = Buffer End If End If End Function




Reply With Quote
