如何使“我的文档”在DriveBox中显示?或用什么方法实现同类功能,望高手赐教,谢谢!

解决方案 »

  1.   

     Const CSIDL_PERSONAL As Long = &H5
    Private Declare Function SHGetSpecialFolderLocation _
            Lib "shell32.dll" _
            (ByVal hwndOwner As Long, _
            ByVal nFolder As Long, _
            pidl As Long) As Long
            
          Private Declare Function SHGetPathFromIDList _
            Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
            (ByVal pidl As Long, _
            ByVal pszPath As String) As Long
    Private Function GetSpecialPath(hwnd, CSIDL As Long) As String '获得windows特殊文件夹路径的自定义函数
        Dim r As Long
        Dim path As String
        Dim pidl As Long
       
        '根据指定的文件夹获得pidl
        r = SHGetSpecialFolderLocation(hwnd, CSIDL, pidl)
       
        If r = NOERROR Then
            path = Space$(512)
            r = SHGetPathFromIDList(ByVal pidl, ByVal path)
            GetSpecialPath = Left$(path, InStr(path, Chr$(0)) - 1)
            Exit Function
        End If    GetSpecialPath = ""
        
    End FunctionPrivate Sub Form_Load()
     
    Dir1.path = GetSpecialPath(Me.hwnd, CSIDL_PERSONAL) & "\"
    End Sub
      

  2.   

    在DriveBox中显示?我这是DirListBox!在DriveBox中显示目录?
      

  3.   

    啊,对不起错了,是DirListBox。
      

  4.   

    为什么“Dir1.Dir1”提示“未找到数据或方法”呢?