Тема: WinAPI в Delphi
Показать сообщение отдельно

  #7  
Старый 19.02.2010, 18:49
transserg
Участник форума
Регистрация: 02.07.2008
Сообщений: 132
Провел на форуме:
1035284

Репутация: 52
Отправить сообщение для transserg с помощью ICQ
По умолчанию

Код:
Procedure ScanRegistry(RootKey:HKEY;SubKey:String);
  var
    hSubKey:HKEY;
    NumKey,NumValue:DWORD;
    NameKey:Pointer;
    NameValue:Pointer;
    BufSize:DWORD;
    KeyError,ValueError:integer;
  begin
    NumKey:=0;
    NumValue:=0;
    BufSize:=2048;
    if ThreadExit then
      exit;
    GetMem(NameValue,BufSize);
    GetMem(NameKey,BufSize);
    try
      if RegOpenKeyEx(RootKey, PChar(SubKey),0,KEY_ALL_ACCESS,hSubKey)=ERROR_SUCCESS then
        begin
          ValueError:=RegEnumValue(hSubKey,NumValue,NameValue,BufSize, nil, nil, nil, nil);
          if PChar(NameValue)<>'' then
            begin
              ResultAnalize(RootKey,PChar(SubKey),NameValue);
            end;
          inc(NumValue);
          while ValueError=ERROR_SUCCESS do
            begin
              BufSize:=2048;
              try
                ValueError:=RegEnumValue(hSubKey,NumValue,NameValue,BufSize, nil, nil, nil, nil);
                if ValueError=ERROR_SUCCESS then
                  if PChar(NameValue)<>'' then
                    begin
                      ResultAnalize(RootKey,PChar(SubKey),NameValue);
                      inc(TotalValue);
                    end;
              finally
                inc(NumValue);
              end;
            end;
          Sleep(2);
          KeyError:=ERROR_SUCCESS;
          while KeyError=ERROR_SUCCESS do
            begin
              BufSize:=2024;
              KeyError:=RegEnumKeyEx(hSubKey,NumKey,NameKey,BufSize,nil,nil,nil,nil);
              inc(TotalKeys);
              if KeyError=ERROR_SUCCESS then
                if SubKey='' then
                  ScanRegistry(RootKey,PChar(Concat(SubKey,PChar(NameKey))))
                else
                  ScanRegistry(RootKey,PChar(Concat(SubKey,'\',PChar(NameKey))));
              inc(NumKey);
            end;
        end;
    finally
      FreeMem(NameKey);
      FreeMem(NameValue);
      RegCloseKey(hSubKey);
    end;
  end;
процедура обхода дерева реестра
первый параметр подраздел один из
Код:
                      HKEY_CLASSES_ROOT 
                      HKEY_CURRENT_USER 
                      HKEY_LOCAL_MACHINE
                      HKEY_USERS           
                      HKEY_PERFORMANCE_DATA 
                      HKEY_CURRENT_CONFIG   
                      HKEY_DYN_DATA
второй параметр это ключ с которого начнется перебор если пустой то будет перебирать с корня под раздела
Код:
ResultAnalize(RootKey,PChar(SubKey),NameValue);
процедура анализа в которой ты собственно и удовлетворяют ли считанные данные условию поиска
 
Ответить с цитированием