Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Wie kann man "zuletzt verwendete Dokumente" auslesen??? (https://www.delphipraxis.net/13948-wie-kann-man-zuletzt-verwendete-dokumente-auslesen.html)

max666 29. Dez 2003 18:49


Wie kann man "zuletzt verwendete Dokumente" ausles
 
Hallo!

Ich möchte alle LNK-Dateien im Verzeichnis "zuletzt verwendete Dokumente" auslesen.

Mit

path:='C:\Dokumente und Einstellungen\max\zuletzt verwendete Dokumente\';
if findfirst(path + '*.*', faDirectory or faAnyFile, searchrec) = 0 then repeat
if (searchrec.Attr and faDirectory)=faDirectory then begin
...


klappt das nicht.

Hat jemand eine Idee!

Gruß aus dem Emsland
Max

Alexander 29. Dez 2003 18:55

Re: Wie kann man "zuletzt verwendete Dokumente" au
 
Das sieht für mich nach einem ganz gewöhnlichen Ordner aus. Allerdings heißt er in Wirklichkeit "recent" und nciht "zuletzt verwendete Dokumente".
Kuck dir mal FindFirst, FindNext,... an.

mirage228 29. Dez 2003 19:09

Re: Wie kann man "zuletzt verwendete Dokumente" au
 
Hi,

den Inhalt eines Ordners kannst du mit dieser Funktion ermitteln:

Delphi-Quellcode:
  procedure FileList(sPath, sExt: string; bRecurse: boolean; List: TStrings);
  var
    f,
    f2: TSearchRec;
  begin
    if FindFirst(sPath + '*.*', faAnyFile, f) = 0 then
    begin
     if FindFirst(sPath + sExt, faAnyFile, f2) = 0 then
     begin
       List.Add(sPath + f2.Name);
       while FindNext(f2) = 0 do
         if (f2.Name <> '.') and (f2.Name <> '..') then List.Add(sPath + f2.Name);
     end;
     while FindNext(f) = 0 do
       if ((f.Attr and faDirectory) = faDirectory) and (f.Name <> '.')
         and (f.Name <> '..') and (bRecurse) then
           FileList(sPath + f.Name + '\', sExt, bRecurse, List);
    end; {if} 
    FindClose(f);
  end;
mfG
mirage228

toms 29. Dez 2003 19:43

Re: Wie kann man "zuletzt verwendete Dokumente" au
 
Zitat:

Ich möchte alle LNK-Dateien im Verzeichnis "zuletzt verwendete Dokumente" auslesen.
Delphi-Quellcode:
uses
  ActiveX, ShlObj;

function GetRecentFilesPath: string;
var
  shellMalloc: IMalloc;
  ppidl: PItemIdList;
  PerDir: string;
begin
  ppidl := nil;
  try
    if SHGetMalloc(shellMalloc) = NOERROR then
    begin
      SHGetSpecialFolderLocation(0, CSIDL_RECENT, ppidl);
      SetLength(Result, MAX_PATH);
      if not SHGetPathFromIDList(ppidl, PChar(Result)) then
        raise Exception.Create('SHGetPathFromIDList failed : invalid pidl');
      SetLength(Result, lStrLen(PChar(Result)));
    end;
  finally
    if ppidl <> nil then
      shellMalloc.free(ppidl);
  end;
end;

procedure FileList(sPath, sExt: string ; List: TStrings);
var
  dir: TSearchRec;
  ret: Integer;
begin
  ret := FindFirst(sPath + '\' + sExt, faAnyFile, dir);
  if ret <> NO_ERROR then
    Exit;
  try
    while ret = NO_ERROR do
    begin
      if (dir.Name <> '.') and (dir.Name <> '..') then
        List.Add(dir.name);
      ret := FindNext(Dir);
    end;
  finally
    FindClose(dir);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  FileList(GetRecentFilesPath, '*.lnk', ListBox1.Items);
end;

max666 29. Dez 2003 20:03

Re: Wie kann man "zuletzt verwendete Dokumente" au
 
Hallo!

Und Danke erste einmal für die sehr schnellen und sehr ausführlichen Antworten. Echt spitze!!!

Sowohl die Antwort mit "CSIDL_RECENT", als auch die anderen Antworten haben mir sehr geholfen, denn mein Problem ist gelöst.

Vielen Dank und ich empfehle Euch weiter.

Gruß
Max666


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:32 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz