Results 1 to 40 of 66

Thread: [VB6, twinBASIC] ucDriveCombo - A modern DriveList replacement

Hybrid View

  1. #1
    Fanatic Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    762

    Re: [VB6, twinBASIC] ucDriveCombo - A modern DriveList replacement

    Quote Originally Posted by fafalone View Post
    Project Updated - Version 1.4

    So for network paths, I stuck pretty closely to the proposed version earlier for WNetGetUniversalNameW; I don't know why it wasn't working. I put a mapped drive on a VM, and confirmed it's working now.

    Here's what I wound up doing:

    Code:
    Private Sub SetOldName(sPath As String, sLetter As String, nIdx As Long)
        Dim sTmp As String
        Dim sOld As String
        Dim dwFlag As Long
        sOld = LCase$(sLetter) & ":"
        If PathIsNetworkPathW(StrPtr(sPath)) Then
            sOld = GetOldNetName(sOld)
        Else
            sTmp = String$(34, 0)
            If GetVolumeInformationW(StrPtr(sPath), StrPtr(sTmp), 34, ByVal 0, 0, dwFlag, 0, 0) Then
                If InStr(sTmp, vbNullChar) > 1 Then
                    sTmp = Left$(sTmp, InStr(sTmp, vbNullChar) - 1)
                    sOld = sOld & " [" & sTmp & "]"
                End If
            End If
        End If
        mDrives(nIdx).NameOld = sOld
    End Sub
    Private Function GetOldNetName(ByVal sLetter As String) As String
        Dim tn As UNIVERSAL_NAME_INFOW
        Dim lRet As Long
        Dim bt() As Byte
        Dim cb As Long
        ReDim bt((MAX_PATH * 2 + 1) + LenB(tn))
        cb = UBound(bt) + 1
        lRet = WNetGetUniversalNameW(StrPtr(sLetter), UNIVERSAL_NAME_INFO_LEVEL, bt(0), cb)
        If lRet = S_OK Then
            CopyMemory tn, bt(0), LenB(tn)
            Dim sPath As String
            Dim cch As Long
            cch = lstrlenW(ByVal tn.lpUniversalName)
            If cch = 0 Then
                GetOldNetName = sLetter
                Exit Function
            End If
            sPath = String$(cch, 0)
            CopyMemory ByVal StrPtr(sPath), ByVal tn.lpUniversalName, cch * 2
            GetOldNetName = sLetter & " [" & sPath & "]"
            Exit Function
        Else
            Debug.Print "GetOldNetName->Error: " & lRet
        End If
        GetOldNetName = sLetter
    End Function
    If something isn't right let me know.
    WNetGetUniversalNameW is working now. Great job. A couple of slight differences between ucDriveCombo.Drive value and VB6.DriveListBox for network shares are:

    1. Yours includes a trailing backslash after the Share where VB's does not.
    2. Drive letter is lower case in VB6 but in yours it's upper case

    Name:  ucDriveComboShare fafalone working.jpg
Views: 307
Size:  17.5 KB
    Last edited by AAraya; Apr 25th, 2024 at 08:59 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width