• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

"My Recent Documents" into a List

How do I get a list of all the files in the "My Recent Documents" Folder?  
Support for windows versions before Windows 2000 is not necessary.

I think that this question has two parts:

1) How do I find the correct folder where the file shorcuts (".lnk" files) are stored? I have noticed that this folder can be have various names, and the path to the folder depends on the logged in user's name.  So, how can my program know what the correct path is?

2) How do I get the original file path from the ".lnk" file?

Thank you,

Will.
0
wolsen
Asked:
wolsen
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
din345Commented:
you can find the recent documents in the registry, in this key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs
0
 
din345Commented:
here you can get the original path from the .lnk-file: http://delphi.about.com/od/windowsshellapi/l/aa072704a.htm
0
 
mokuleCommented:
The folder You can get by

procedure TForm1.Button1Click(Sender: TObject);
var
  PIDL: PItemIDList;
  Path: array[0..MAX_PATH] of Char;
begin
  SHGetSpecialFolderLocation(Handle, CSIDL_RECENT, PIDL);
  SHGetPathFromIDList(PIDL, Path);
  Edit1.Text := StrPas(Path);
end;

mokule
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
mokuleCommented:
You can place  TFileListBox on  a form and open such files like this

procedure TForm1.Button1Click(Sender: TObject);
var
  PIDL: PItemIDList;
  Path: array[0..MAX_PATH] of Char;
begin
  SHGetSpecialFolderLocation(Handle, CSIDL_RECENT, PIDL);
  SHGetPathFromIDList(PIDL, Path);
  Edit1.Text := StrPas(Path);
  FileListBox1.Directory := Edit1.Text;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ShellExecute(Handle,'open',PChar(FileListBox1.FileName),nil,nil,SW_SHOW);
end;

0
 
HypoviaxCommented:
For 1 :

If you install jvcl library from: http://jvcl.sourceforge.net then you can add a component called jvDirectories (jvSystem tab). This component will provide you with a list of many different directories including recent file lists. This list is adaptable and so it would appropriately change for different users

For 2:

Use din345 second post

Regards,

Hypoviax :: www.lhco.ws
0
 
HypoviaxCommented:
Sorry for adding my website to by signature - please remove it
0
 
_JHL_Commented:
mokule what lib I have to put iin Uses to run your prg..??

0
 
mokuleCommented:
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, shlobj, StdCtrls, shellapi, FileCtrl;

mokule
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now