Results 1 to 2 of 2

Thread: Recent Documents

  1. #1

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Recent Documents

    I'm sure there is an API or two involved, so I'm posting this here.

    I need to be able to retrieve, and display, the full path to the Recent Documents folder. How would I do that?
    Beantown Boy
    Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.

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

    Re: Recent Documents

    VB Code:
    1. Option Explicit
    2.  
    3. Private Const SPECIALFOLDER_PROGRAMS = 2 '// Program Files
    4. Private Const SPECIALFOLDER_DOCUMENTS = 5 '// My Documents
    5. Private Const SPECIALFOLDER_FAVORITES = 6 '// Favourites
    6. Private Const SPECIALFOLDER_STARTUP = 7 '// Startup Folder
    7. Private Const SPECIALFOLDER_RECENT = 8 '// Recent Documents
    8. Private Const SPECIALFOLDER_SENDTO = 9 '// Send To Folder
    9. Private Const SPECIALFOLDER_STARTMENU = 11 '// Start Menu
    10. Private Const SPECIALFOLDER_DESKTOPFOLDER = 16 '// Desktop folder
    11. Private Const SPECIALFOLDER_NETHOOD = 19 '// NetHood Folder
    12.  
    13. Private Const MAX_PATH As Integer = 260
    14.  
    15. Private Type HITEMID
    16.     cb As Long
    17.     abID As Byte
    18. End Type
    19.  
    20. Private Type ITEMIDLIST
    21.     mkid As HITEMID
    22. End Type
    23.  
    24. Private Declare Function SHGetSpecialFolderLocation Lib "Shell32.dll" _
    25. (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
    26. Private Declare Function SHGetPathFromIDList Lib "Shell32.dll" Alias _
    27. "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
    28.  
    29. Private Function FindSpecialFolder(lngSpecialFolder As Long) As String
    30. Dim sPath As String
    31. Dim ItemID As ITEMIDLIST
    32. ' Info is stored in the IDL structure.
    33. FindSpecialFolder = ""
    34. If SHGetSpecialFolderLocation(Form1.hWnd, lngSpecialFolder, ItemID) = 0 Then
    35.     ' Get the path from the ID list, and return the folder.
    36.     sPath = Space$(MAX_PATH)
    37.     If SHGetPathFromIDList(ByVal ItemID.mkid.cb, ByVal sPath) Then
    38.         FindSpecialFolder = Left$(sPath, InStr(sPath, vbNullChar) - 1) & "\"
    39.     End If
    40. End If
    41. End Function
    42.  
    43. Private Sub Command1_Click()
    44. Dim sMyFolder As String
    45. sMyFolder = FindSpecialFolder(SPECIALFOLDER_RECENT)
    46. Text1.Text = sMyFolder
    47. End Sub
    Last edited by Hack; Feb 11th, 2005 at 02:58 PM.

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