BSOne.SFC/Tocsg.Module/MonSecu/ThdCollectRecentFile.pas

109 lines
2.7 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{*******************************************************}
{ }
{ 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 <20><><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD> <20><>ü <20><><EFBFBD>δ<EFBFBD> <20>Ʒ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20>ִ<EFBFBD>.
// C:\Users\tocsg\AppData\Roaming\Microsoft\Windows\Recent\
{ TThdCollectRecentFile }
Constructor TThdCollectRecentFile.Create;
begin
Inherited Create;
end;
procedure TThdCollectRecentFile.Execute;
begin
end;
end.