{*******************************************************} { } { ThdCollectRecentFile } { } { Copyright (C) 2022 kku } { } {*******************************************************} unit ThdCollectRecentFile; interface uses Tocsg.Thread, System.SysUtils, System.Classes, Winapi.Windows; type TThdCollectRecentFile = class(TTgThread) protected procedure Execute; override; public Constructor Create; end; function ExtrRecentFileFromReg: String; implementation uses System.Win.Registry, Tocsg.Safe, Tocsg.Strings, Tocsg.Hex; function ExtrRecentFileFromReg: String; var ValList: TStringList; function ExtrRecentFromKey(sKey: String): String; var Reg: TRegistry; i: Integer; pBuf: TBytes; begin Result := ''; ValList.Clear; Guard(Reg, TRegistry.Create); Reg.RootKey := HKEY_CURRENT_USER; if Reg.OpenKey(sKey, false) then begin Reg.GetValueNames(ValList); for i := 0 to ValList.Count - 1 do if StrToIntDef(ValList[i], -1) > -1 then begin ConvStrToBin(StringReplace(Reg.GetDataAsString(ValList[i]), ',', '', [rfReplaceAll]), pBuf); SumString(Result, PChar(pBuf), #13#10); end; end; end; const REG_KEY_RECENTDOCS = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs'; var Reg: TRegistry; NameList: TStringList; i: Integer; sRecentFiles: String; begin Result := ''; Guard(ValList, TStringList.Create); Guard(NameList, TStringList.Create); Guard(Reg, TRegistry.Create); Reg.RootKey := HKEY_CURRENT_USER; if Reg.OpenKey(REG_KEY_RECENTDOCS, false) then begin Reg.GetKeyNames(NameList); for i := 0 to NameList.Count - 1 do begin if CompareText(NameList[i], 'Folder') = 0 then continue; sRecentFiles := ExtrRecentFromKey(REG_KEY_RECENTDOCS + '\' + NameList[i]); if sRecentFiles <> '' then SumString(Result, sRecentFiles, #13#10); end; end; end; // HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Excel\File MRU // HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\PowerPoint\File MRU // HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Word\File MRU // HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs // RecentDocs ÆÄÀϵéÀÇ Àüü °æ·Î´Â ¾Æ·¡ °æ·ÎÀÇ ¸µÅ©ÆÄÀÏ¿¡¼­ Á¤º¸¸¦ ¾òÀ» ¼ö ÀÖ´Ù. // C:\Users\tocsg\AppData\Roaming\Microsoft\Windows\Recent\ { TThdCollectRecentFile } Constructor TThdCollectRecentFile.Create; begin Inherited Create; end; procedure TThdCollectRecentFile.Execute; begin end; end.