![]() |
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 |
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. |
Re: Wie kann man "zuletzt verwendete Dokumente" au
Hi,
den Inhalt eines Ordners kannst du mit dieser Funktion ermitteln:
Delphi-Quellcode:
mfG
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; mirage228 |
Re: Wie kann man "zuletzt verwendete Dokumente" au
Zitat:
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; |
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 11:38 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz