在菜单栏增加一个功能“显示”
在ListView中选定一个(或多个)文件,
点击“显示”后希望获得所选文件的完整路径。
如何能得到?请指点。
谢谢!

解决方案 »

  1.   

    现在根本找不到关于 Shell接口 的资料
      

  2.   

    ……那玩意用的sub classing……
      

  3.   

    ……那玩意用的sub classing……--------------------------------那不是关键
    纯API建立TreeView、ListView并不困难难就难在它是使用 Shell接口 得到文件信息的
    而VB对COM的支持封装得太好了,无法直接对某个接口进行操作
    所以那个程序是自己写的接口声明,与标准的不同
    再加上找不到这方面系统点的资料
      

  4.   

    ' Returns an absolute pidl's path only (doesn't rtn display names!)
    Public Function GetPathFromPIDL(pidl As Long) As String
      Dim sPath As String * MAX_PATH   ' 260
      If (SUCCEEDED(SHGetPathFromIDList(pidl, sPath))) Then
        GetPathFromPIDL = GetStrFromBufferA(sPath)
      End If
    End FunctionPublic Function DoLVNotify(hwndForm As Long, lParam As Long) As Long
    ..............
        Case NM_CLICK
            Dim lSelItem As Long
            
          
            ' Get the selected listview item's index
            lSelItem = ListView_GetSelectedItem(hwndLV)
            If (lSelItem = -1) Then Exit Function
          
            ' Get the selected listview item's LVITEM struct
            lvi.mask = LVIF_PARAM
            lvi.iItem = lSelItem
            If (ListView_GetItem(hwndLV, lvi) = False) Then Exit Function
          
            ' Fill the item's ITEMDATA struct from it's pointer
            MoveMemory lvid, ByVal lvi.lParam, Len(lvid)
            Debug.Print "Path " & GetPathFromPIDL(lvid.pidlRel)
    .....................
    End Function
      

  5.   

    To:bbe
    请问lvid应该Dim为什么?
      

  6.   

    这部分代码还不是核心
    只是处理TreeView的通知消息(相当于VB的事件)而已
      

  7.   

    Dim lvid As LVITEMDATA 你是要问这个吗?
      

  8.   

    Dim lvid As LVITEMDATA
    =>
    Compile error:
    User-defined type not defined
      

  9.   

    ' Contains pertinent info we'll use a lot for each inserted listview item.
    ' Each item's LVITEM lParam member will contain a pointer to this struct.
    Public Type LVITEMDATA
       isfParent As IShellFolder   ' pointer to the parent item's shell folder interface
       pidlRel As Long                ' item's pidl (relative to it's parent folder)
       ulAttribs As Long              ' item's SHGAO_ attributes
    End Type有可能是类型库ISHF_EX.TLB的引用问题
      
      

  10.   

    Dim lvid As LVITEMDATA 现在可以了运行时,点ListView1的文件(夹)出错:
    vb6.exe - 应用程序错误
    "0x082444f6"指令引用的"0x082444f6"内存。该内存不能为"read"
      

  11.   

    我的没有问题,你可以下载看看
    http://folderprotector.myrice.com/edeskvb2.rar
      

  12.   

    先谢谢bbe大侠
    我把您给的代码放到edeskvb2就行了
    (我开始是用VBExplorer测试的,不行)另:上面的连接下不了再次谢谢!