|
-
Jan 23rd, 2006, 09:37 AM
#1
Thread Starter
Member
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.
-
Jan 24th, 2006, 02:12 AM
#2
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
-
Jan 24th, 2006, 09:46 AM
#3
Re: Retrieve Recent Documents Paths !!!!!
 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. 
-
Jan 31st, 2006, 04:03 AM
#4
Addicted Member
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.
-
Jan 31st, 2006, 08:52 AM
#5
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:
Option Explicit
Private Const CSIDL_RECENT = 8
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 fGetSpecialFolder(plngCSIDL As Long) As String
Dim sPath As String
Dim IDL As ITEMIDLIST
fGetSpecialFolder = vbNullString
If SHGetSpecialFolderLocation(Form1.hwnd, plngCSIDL, IDL) = 0 Then
sPath = Space$(MAX_PATH)
If SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath) Then
fGetSpecialFolder = Left$(sPath, InStr(sPath, vbNullChar) - 1) & "\"
End If
End If
End Function
Private Sub Command1_Click()
Dim strPath As String
Dim strLoadFiles As String
strPath = fGetSpecialFolder(CSIDL_RECENT)
List1.Clear
strLoadFiles = Dir(strPath & "*.*")
Do While strLoadFiles > vbNullString
List1.AddItem strLoadFiles
strLoadFiles = Dir
Loop
End Sub
Last edited by Hack; Jan 31st, 2006 at 08:55 AM.
-
Jan 31st, 2006, 02:16 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|