Results 1 to 6 of 6

Thread: Retrieve Recent Documents Paths !!!!!

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    43

    Retrieve Recent Documents Paths !!!!!

    Hi all,

    I want to retrieve the list of recent documents that is shown on the Start Menu and store the Documents full paths in an array.

    I understand that these recent documents are stored in the following Registry address :
    HKEY_LOCAL_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs

    Any pointers ?

    Any help much appreciated.

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Retrieve Recent Documents Paths !!!!!

    I am afraid there is any pointers to this. If at all required you can store the registry entries in an array

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Retrieve Recent Documents Paths !!!!!

    Quote Originally Posted by BLUE_SEA
    Hi all,

    I want to retrieve the list of recent documents that is shown on the Start Menu and store the Documents full paths in an array.

    I understand that these recent documents are stored in the following Registry address :
    HKEY_LOCAL_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs

    Any pointers ?

    Any help much appreciated.
    What part of this are you having trouble with?


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    Addicted Member
    Join Date
    May 2004
    Location
    Nagpur, India
    Posts
    228

    Re: Retrieve Recent Documents Paths !!!!!

    Open the Registry using RegOpenKey.
    RegOpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs", lngKeyHandle)

    Now, time to enumerate and get all the values:
    Use RegEnumValue
    Pass the lngKeyHandle to RegEnumValue
    Loop until the return value of RegEnumValue is 0.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Retrieve Recent Documents Paths !!!!!

    If you want to get a list of what is in your recent documents folder, then this should work without having to go into the registry. I'm displaying all of the Recent Documents in a ListBox, but you can do whatever you want.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const CSIDL_RECENT = 8
    4. Private Const MAX_PATH As Integer = 260
    5.  
    6. Private Type HITEMID
    7.     cb As Long
    8.     abID As Byte
    9. End Type
    10.  
    11. Private Type ITEMIDLIST
    12.     mkid As HITEMID
    13. End Type
    14.  
    15. Private Declare Function SHGetSpecialFolderLocation Lib "Shell32.dll" _
    16. (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
    17.  
    18. Private Declare Function SHGetPathFromIDList Lib "Shell32.dll" Alias "SHGetPathFromIDListA" _
    19. (ByVal pidl As Long, ByVal pszPath As String) As Long
    20.  
    21. Private Function fGetSpecialFolder(plngCSIDL As Long) As String
    22. Dim sPath As String
    23. Dim IDL As ITEMIDLIST
    24.  
    25. fGetSpecialFolder = vbNullString
    26. If SHGetSpecialFolderLocation(Form1.hwnd, plngCSIDL, IDL) = 0 Then
    27.  
    28.     sPath = Space$(MAX_PATH)
    29.     If SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath) Then
    30.         fGetSpecialFolder = Left$(sPath, InStr(sPath, vbNullChar) - 1) & "\"
    31.     End If
    32. End If
    33. End Function
    34.  
    35. Private Sub Command1_Click()
    36. Dim strPath As String
    37. Dim strLoadFiles As String
    38. strPath = fGetSpecialFolder(CSIDL_RECENT)
    39. List1.Clear
    40. strLoadFiles = Dir(strPath & "*.*")
    41. Do While strLoadFiles > vbNullString
    42.    List1.AddItem strLoadFiles
    43.    strLoadFiles = Dir
    44. Loop
    45. End Sub
    Last edited by Hack; Jan 31st, 2006 at 08:55 AM.

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Retrieve Recent Documents Paths !!!!!

    @Hack, you could use SHGetSpecialFolderPath directly instead of using both SHGetSpecialFolderLocation and SHGetPathFromIDList.
    Code:
    Private Declare Function SHGetSpecialFolderPath _
     Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" ( _
        ByVal hwnd As Long, _
        ByVal pszPath As String, _
        ByVal csidl As Long, _
        ByVal fCreate As Long _
    ) As Long
    You would call that function like this:
    Code:
    Dim sPath As String
    sPath = String$(MAX_PATH, vbNullChar)
    Call SHGetSpecialFolderPath(0&, sPath, CSIDL_RECENT, False)
    sPath = Left$(sPath, InStr(sPath, vbNullChar) - 1)

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