Код:
procedure ProSearchReg(SearchStr:string; SearchKey, SearchParam, SearchVal:boolean=true); //процедура поиска
//строка поиска, искать в ключах, в параметрах, в значениях
var
count,i: integer=0;
SKey, SParam, SVal: string;
HKEY_USERSLines : TStrings; //список подразделов HKEY_USERS
begin
HKEY_USERSLines := TStringList.Create;
SearchStr:=LowerCase(SearchStr);//к нижнему регистру для сравнения
if SearchKey then SKey:='true' else SKey := 'false';
if SearchParam then SParam:='true' else SParam := 'false';
if SearchVal then SVal:='true' else SVal := 'false';
//заголовок INI файла
INIStrParamWrite(GetAVZDirectory+'Search.ini','Parametrs','StrSearch',SearchStr);
INIStrParamWrite(GetAVZDirectory+'Search.ini','Parametrs','SearchKey',SKey);
INIStrParamWrite(GetAVZDirectory+'Search.ini','Parametrs','SearchParam',SParam);
INIStrParamWrite(GetAVZDirectory+'Search.ini','Parametrs','SearchVal',SVal);
//чистка разделов INI файла HKLM и HKEY_USERS
INIEraseSection(GetAVZDirectory+'Search.ini','HKLM');
INIEraseSection(GetAVZDirectory+'Search.ini','HKEY_USERS');
//поиск в HKLM
count:=FuncSearchReg('HKLM','HARDWARE',SearchStr, count, SearchKey, SearchParam, SearchVal);
count:=FuncSearchReg('HKLM','SAM',SearchStr, count, SearchKey, SearchParam, SearchVal);
count:=FuncSearchReg('HKLM','SECURITY',SearchStr, count, SearchKey, SearchParam, SearchVal);
count:=FuncSearchReg('HKLM','SOFTWARE',SearchStr, count, SearchKey, SearchParam, SearchVal);
count:=FuncSearchReg('HKLM','SYSTEM',SearchStr, count, SearchKey, SearchParam, SearchVal);
INIStrParamWrite(GetAVZDirectory+'Search.ini','Parametrs','HKLM_Count',inttostr(count));//количество найденных ключей, значений, параметров в разделе HKLM
count:=0;
//формирование списка разделов HKEY_USERSLines
RegKeyEnumKey('HKLM','SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList', HKEY_USERSLines);//узнаем какие подразделы в HKEY_USERS
HKEY_USERSLines.insert(0,'.DEFAULT');
i:=0;
while i < HKEY_USERSLines.count do
begin
if RegKeyExists('HKEY_USERS', HKEY_USERSLines[i]+'_Classes') then HKEY_USERSLines.insert(i+1,HKEY_USERSLines[i]+'_Classes');
i:=i+1;
end;
//поиск в HKEY_USERS
for i:=0 to HKEY_USERSLines.count-1 do
count:=FuncSearchReg('HKEY_USERS',HKEY_USERSLines[i],SearchStr, count, SearchKey, SearchParam, SearchVal);
INIStrParamWrite(GetAVZDirectory+'Search.ini','Parametrs','HKEY_USERS_Count',inttostr(count));//количество найденных ключей, значений, параметров в разделе HKEY_USERS
HKEY_USERSLines.free;
end;
Function FuncSearchReg(ARoot, AKey, SearchStr:string; count: integer; SearchKey, SearchParam, SearchVal:boolean): integer;
var
KeyLines, ValLines : TStrings;
i,j : integer;
binary:boolean;
begin
KeyLines := TStringList.Create; //список ключей
ValLines := TStringList.Create; //список параметров
if SearchKey then
begin
if Pos(SearchStr, LowerCase(AKey))<>0 then
begin
INIStrParamWrite(GetAVZDirectory+'Search.ini',ARoot,'Key'+inttostr(count+1),AKey);
INIStrParamWrite(GetAVZDirectory+'Search.ini',ARoot,'Param'+inttostr(count+1),'');
INIStrParamWrite(GetAVZDirectory+'Search.ini',ARoot,'Value'+inttostr(count+1),'');
count:=count+1;
end;
end;
RegKeyEnumVal(ARoot,AKey, ValLines);//чтение параметров ключа AKey
if SearchParam then
begin
for i:= 0 to ValLines.Count-1 do
begin
if Pos(SearchStr, LowerCase(ValLines[i]))<>0 then
begin
INIStrParamWrite(GetAVZDirectory+'Search.ini',ARoot,'Key'+inttostr(count+1),AKey);
INIStrParamWrite(GetAVZDirectory+'Search.ini',ARoot,'Param'+inttostr(count+1),ValLines[i]);
INIStrParamWrite(GetAVZDirectory+'Search.ini',ARoot,'Value'+inttostr(count+1),'');
count:=count+1;
end;
end;
end;
if SearchVal then
begin
for i:= 0 to ValLines.Count-1 do
begin
if Pos(SearchStr, LowerCase(RegKeyStrParamRead(ARoot, AKey, ValLines[i])))<>0 then
begin
j:=0;
binary:=false;
for j:=0 to Length(RegKeyStrParamRead(ARoot, AKey, ValLines[i]))-1 do
if Ord(copy(RegKeyStrParamRead(ARoot, AKey, ValLines[i]), j, 2))<32 then //проверка на бинарность
begin
binary:=true;
break;
end;
if(not binary) then
begin
INIStrParamWrite(GetAVZDirectory+'Search.ini',ARoot,'Key'+inttostr(count+1),AKey);
INIStrParamWrite(GetAVZDirectory+'Search.ini',ARoot,'Param'+inttostr(count+1),ValLines[i]);
INIStrParamWrite(GetAVZDirectory+'Search.ini',ARoot,'Value'+inttostr(count+1),RegKeyStrParamRead(ARoot, AKey, ValLines[i]));
count:=count+1
end;
end;
end;
end;
RegKeyEnumKey(ARoot,AKey, KeyLines);
for i:= 0 to KeyLines.Count-1 do
begin
count:=FuncSearchReg(ARoot, NormalDir(AKey)+LowerCase(KeyLines[i]), SearchStr, count, SearchKey, SearchParam, SearchVal);
end;
KeyLines.free;
ValLines.free;
result:=count;
end;
begin
ProSearchReg('webalta');
executerepair(10);
end.
Файл Search.ini из папки АВЗ прикрепите к следующему сообщению.