|
-
Feb 11th, 2005, 01:16 PM
#1
Thread Starter
Frenzied Member
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.
-
Feb 11th, 2005, 02:54 PM
#2
Re: Recent Documents
VB Code:
Option Explicit
Private Const SPECIALFOLDER_PROGRAMS = 2 '// Program Files
Private Const SPECIALFOLDER_DOCUMENTS = 5 '// My Documents
Private Const SPECIALFOLDER_FAVORITES = 6 '// Favourites
Private Const SPECIALFOLDER_STARTUP = 7 '// Startup Folder
Private Const SPECIALFOLDER_RECENT = 8 '// Recent Documents
Private Const SPECIALFOLDER_SENDTO = 9 '// Send To Folder
Private Const SPECIALFOLDER_STARTMENU = 11 '// Start Menu
Private Const SPECIALFOLDER_DESKTOPFOLDER = 16 '// Desktop folder
Private Const SPECIALFOLDER_NETHOOD = 19 '// NetHood Folder
Private Const MAX_PATH As Integer = 260
Private Type HITEMID
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As HITEMID
End Type
Private Declare Function SHGetSpecialFolderLocation Lib "Shell32.dll" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "Shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Function FindSpecialFolder(lngSpecialFolder As Long) As String
Dim sPath As String
Dim ItemID As ITEMIDLIST
' Info is stored in the IDL structure.
FindSpecialFolder = ""
If SHGetSpecialFolderLocation(Form1.hWnd, lngSpecialFolder, ItemID) = 0 Then
' Get the path from the ID list, and return the folder.
sPath = Space$(MAX_PATH)
If SHGetPathFromIDList(ByVal ItemID.mkid.cb, ByVal sPath) Then
FindSpecialFolder = Left$(sPath, InStr(sPath, vbNullChar) - 1) & "\"
End If
End If
End Function
Private Sub Command1_Click()
Dim sMyFolder As String
sMyFolder = FindSpecialFolder(SPECIALFOLDER_RECENT)
Text1.Text = sMyFolder
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|