Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002548 [JEDI VCL] 00 JVCL Components minor always 2005-01-24 10:54 2005-01-25 15:05
Reporter anonymous View Status public  
Assigned To user72
Priority normal Resolution fixed  
Status resolved   Product Version 3.00 BETA 2
Summary 0002548: TJvRegistryTreeView doesn't handle special value types (REG_MULTI_SZ, REG_LINK, etc)
Description Due to the use of TRegistry when filling the values listview, TJVRegistryTreeview doesn't show special value types. I've changed the function FillListView, so it can handle these values. Some examples in my machine:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\016
HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\MultifunctionAdapter
Additional Information // Modified function

function RegTypes(AType : Integer) : String;
const
  StrTypes : Array[0..10] of String = ('REG_NONE', 'REG_SZ','REG_EXPAND_SZ',
    'REG_BINARY','REG_DWORD','REG_DWORD_BIG_ENDIAN','REG_LINK','REG_MULTI_SZ',
    'REG_RESOURCE_LIST','REG_FULL_RESOURCE_DESCRIPTOR','REG_RESOURCE_REQUIREMENTS_LIST');
begin
  if (AType >= 0) and (AType <= High(StrTypes)) then
    Result := StrTypes[AType]
  else
    Result := 'UNKNOWN';
end;

function TJvRegistryTreeView.FillListView(Node: TTreeNode): Boolean;
var
  Strings: TStringList;
  I,J: Integer;
  TmpItem: TListItem;
  Buffer: array [0..4095] of Byte;
  S, T: string;
  DefaultSet: Boolean;
  Info: TRegKeyInfo;
  D : Array of Byte;
  DataType : Cardinal;
  Len, Len1 : Cardinal;
begin
  Result := False;
  if not Assigned(FListView) then
    Exit;
  OpenRegistry(Node);
  FListView.Items.BeginUpdate;
  try
    FListView.Items.Clear;
    if FListView.SmallImages = nil then
      FListView.SmallImages := Images;
    if (Node = nil) or (Node = Items.GetFirstNode) then
      Exit;
    { set current root }
    DefaultSet := False;
    if FReg.OpenKeyReadOnly(GetKeyPath(Node)) then
    begin
      Strings := TStringList.Create;
      if FReg.GetKeyInfo(Info) then
      begin
        for I := 0 to Info.NumValues - 1 do
        begin
          Len := Info.MaxValueLen + 1;
          Len1 := Info.MaxDataLen + 1;
          SetLength(S, Len);
          SetLength(D, Len1);
          DataType := 0;
          RegEnumValue(FReg.CurrentKey, I, PChar(S), Len, nil, @DataType, @D[0], @Len1);
          SetLength(S,Len);
        { set default item }
          if (S = '') and not DefaultSet then
          begin
            TmpItem := FListView.Items.Insert(0);
            TmpItem.Caption := FDefaultCaption;
            DefaultSet := True;
          end
          else
          begin
            TmpItem := FListView.Items.Add;
            TmpItem.Caption := S;
          end;
          case DataType of
            REG_SZ, REG_EXPAND_SZ,REG_MULTI_SZ :
              begin
                if DataType = REG_MULTI_SZ then
                  for J := 0 to Pred(Len1) do
                    if D[J] = 0 then
                      D[J] := Ord(' ');
                T := String(PChar(D));
                if (T = '') and AnsiSameText(TmpItem.Caption, FDefaultCaption) then
                  T := FDefaultNoValue;
                TmpItem.ImageIndex := imText;
                TmpItem.SubItems.Add(T);
              end;
            REG_DWORD :
              begin
                TmpItem.ImageIndex := imBin;
                TmpItem.SubItems.Add(Format('0x%.8x (%d)', [Cardinal(D),
                  Cardinal(D)]));
              end;
            REG_NONE:
              begin
                TmpItem.ImageIndex := imText;
                TmpItem.SubItems.Add(RsUnknownCaption);
              end;
            else
            begin
              TmpItem.ImageIndex := imBin;
              TmpItem.SubItems.Add(BufToStr(D, Len1));
            end;
          end;
          TmpItem.SubItems.Add(RegTypes(DataType));
        end;
      end;
      Result := True;
    end;
    { set default item }
    if (Node.Parent <> nil) and not DefaultSet then
    begin
      TmpItem := FListView.Items.Insert(0);
      TmpItem.ImageIndex := imText;
      TmpItem.Caption := FDefaultCaption;
      TmpItem.SubItems.Add(FDefaultNoValue);
      TmpItem.SubItems.Add('REG_SZ');
    end;
  finally
    FListView.Items.EndUpdate;
    CloseRegistry;
  end;
end;
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0006284)
user72
2005-01-25 13:47

Very nice code. Updated in CVS
(0006286)
anonymous (viewer)
2005-01-25 13:55

After tweaking a little, I've seen an error in my code, regarding to DWORD values. The correct is:

REG_DWORD : begin
             TmpItem.ImageIndex := imBin;
             TmpItem.SubItems.Add(Format('0x%.8x (%d)', [Cardinal(Pointer(D)^),
                Cardinal(Pointer(D)^)]));
            end;
(0006289)
user72
2005-01-25 15:05

Thanks. Fixed

- Issue History
Date Modified Username Field Change
2005-01-24 10:54 anonymous New Issue
2005-01-24 10:55 bsonnino Issue Monitored: bsonnino
2005-01-25 13:47 user72 Status new => resolved
2005-01-25 13:47 user72 Resolution open => fixed
2005-01-25 13:47 user72 Assigned To => user72
2005-01-25 13:47 user72 Note Added: 0006284
2005-01-25 13:55 anonymous Status resolved => feedback
2005-01-25 13:55 anonymous Resolution fixed => reopened
2005-01-25 13:55 anonymous Note Added: 0006286
2005-01-25 15:05 user72 Status feedback => resolved
2005-01-25 15:05 user72 Resolution reopened => fixed
2005-01-25 15:05 user72 Note Added: 0006289


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker