Changeset 538


Ignore:
Timestamp:
Aug 6, 2019, 1:55:55 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Use fcl registry.
Location:
Registry
Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • Registry/Demo/RegistryDemo.lpi

    r408 r538  
    1 <?xml version="1.0"?>
     1<?xml version="1.0" encoding="UTF-8"?>
    22<CONFIG>
    33  <ProjectOptions>
    4     <Version Value="9"/>
     4    <Version Value="11"/>
    55    <PathDelim Value="\"/>
    66    <General>
     
    1515      <EnableI18N LFM="False"/>
    1616    </i18n>
    17     <VersionInfo>
    18       <StringTable ProductVersion=""/>
    19     </VersionInfo>
    2017    <BuildModes Count="1">
    2118      <Item1 Name="Default" Default="True"/>
     
    2320    <PublishOptions>
    2421      <Version Value="2"/>
    25       <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
    26       <ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
    2722    </PublishOptions>
    2823    <RunParams>
    29       <local>
    30         <FormatVersion Value="1"/>
    31       </local>
     24      <FormatVersion Value="2"/>
     25      <Modes Count="1">
     26        <Mode0 Name="default"/>
     27      </Modes>
    3228    </RunParams>
    3329    <RequiredPackages Count="2">
    3430      <Item1>
    3531        <PackageName Value="GeneralRegistry"/>
     32        <DefaultFilename Value="..\GeneralRegistry.lpk" Prefer="True"/>
    3633      </Item1>
    3734      <Item2>
     
    4340        <Filename Value="RegistryDemo.lpr"/>
    4441        <IsPartOfProject Value="True"/>
    45         <UnitName Value="RegistryDemo"/>
    4642      </Unit0>
    4743      <Unit1>
     
    5147        <HasResources Value="True"/>
    5248        <ResourceBaseClass Value="Form"/>
    53         <UnitName Value="UFormMain"/>
    5449      </Unit1>
    5550      <Unit2>
     
    5954        <HasResources Value="True"/>
    6055        <ResourceBaseClass Value="DataModule"/>
    61         <UnitName Value="UCore"/>
    6256      </Unit2>
    6357    </Units>
     
    8579      </Options>
    8680    </Linking>
    87     <Other>
    88       <CompilerMessages>
    89         <MsgFileName Value=""/>
    90       </CompilerMessages>
    91       <CompilerPath Value="$(CompPath)"/>
    92     </Other>
    9381  </CompilerOptions>
    9482  <Debugging>
  • Registry/Demo/UCore.lfm

    r392 r538  
    22  OnCreate = DataModuleCreate
    33  OldCreateOrder = False
    4   Height = 233
    5   HorizontalOffset = 428
    6   VerticalOffset = 172
    7   Width = 275
     4  Height = 291
     5  HorizontalOffset = 535
     6  VerticalOffset = 215
     7  Width = 344
     8  PPI = 120
    89  object ActiveRegistry: TGeneralRegistry
    9     left = 42
    10     top = 113
     10    left = 53
     11    top = 141
    1112  end
    1213end
  • Registry/Demo/UCore.pas

    r392 r538  
    3131procedure TCore.DataModuleCreate(Sender: TObject);
    3232begin
     33  TWinRegistry(ActiveRegistry.Backend).OpenKey('\Software\Chronosoft\RegistryDemo', True);
    3334end;
    3435
  • Registry/Demo/UFormMain.lfm

    r408 r538  
    11object FormMain: TFormMain
    2   Left = 222
    3   Height = 454
    4   Top = 162
    5   Width = 707
     2  Left = 354
     3  Height = 568
     4  Top = 285
     5  Width = 884
    66  Caption = 'General registry editor'
    7   ClientHeight = 435
    8   ClientWidth = 707
     7  ClientHeight = 543
     8  ClientWidth = 884
     9  DesignTimePPI = 120
    910  Menu = MainMenu1
    1011  OnShow = FormShow
    11   LCLVersion = '1.1'
     12  LCLVersion = '2.0.2.0'
    1213  object StatusBar1: TStatusBar
    1314    Left = 0
    14     Height = 20
    15     Top = 415
    16     Width = 707
     15    Height = 28
     16    Top = 515
     17    Width = 884
    1718    Panels = <>
     19    ParentFont = False
    1820  end
    1921  object TreeView1: TTreeView
    2022    Left = 0
    21     Height = 415
     23    Height = 515
    2224    Top = 0
    23     Width = 224
     25    Width = 280
    2426    Align = alLeft
    25     DefaultItemHeight = 16
     27    ParentFont = False
    2628    TabOrder = 1
    2729  end
    2830  object Splitter1: TSplitter
    29     Left = 224
    30     Height = 415
     31    Left = 280
     32    Height = 515
    3133    Top = 0
    32     Width = 5
     34    Width = 6
    3335  end
    3436  object ListView1: TListView
    35     Left = 229
    36     Height = 415
     37    Left = 286
     38    Height = 515
    3739    Top = 0
    38     Width = 478
     40    Width = 598
    3941    Align = alClient
    4042    Columns = <   
    4143      item
    4244        Caption = 'Name'
    43         Width = 150
     45        Width = 188
    4446      end   
    4547      item
    4648        Caption = 'Type'
    47         Width = 150
     49        Width = 188
    4850      end   
    4951      item
    5052        Caption = 'Value'
    51         Width = 100
     53        Width = 125
    5254      end>
    5355    OwnerData = True
     56    ParentFont = False
    5457    ReadOnly = True
    5558    RowSelect = True
     
    5962  end
    6063  object MainMenu1: TMainMenu
    61     left = 128
    62     top = 72
     64    left = 160
     65    top = 90
    6366    object MenuItem1: TMenuItem
    6467      Caption = 'File'
     
    7275  end
    7376  object ActionList1: TActionList
    74     left = 128
    75     top = 128
     77    left = 160
     78    top = 160
    7679    object AImport: TAction
    7780      Caption = 'Import'
     
    8992      Caption = 'Modify connection'
    9093    end
     94    object AValueAdd: TAction
     95      Caption = 'Add'
     96      OnExecute = AValueAddExecute
     97    end
     98    object AValueDelete: TAction
     99      Caption = 'Delete'
     100    end
     101    object AValueEdit: TAction
     102      Caption = 'Edit'
     103    end
     104  end
     105  object PopupMenu1: TPopupMenu
     106    left = 492
     107    top = 177
     108    object MenuItem4: TMenuItem
     109      Action = AValueAdd
     110    end
     111    object MenuItem5: TMenuItem
     112      Action = AValueEdit
     113    end
     114    object MenuItem6: TMenuItem
     115      Action = AValueDelete
     116    end
    91117  end
    92118end
  • Registry/Demo/UFormMain.pas

    r392 r538  
    1717    AConnectionDelete: TAction;
    1818    AConnectionModify: TAction;
     19    AValueAdd: TAction;
     20    AValueEdit: TAction;
     21    AValueDelete: TAction;
    1922    AImport: TAction;
    2023    AExport: TAction;
     
    2528    MenuItem2: TMenuItem;
    2629    MenuItem3: TMenuItem;
     30    MenuItem4: TMenuItem;
     31    MenuItem5: TMenuItem;
     32    MenuItem6: TMenuItem;
     33    PopupMenu1: TPopupMenu;
    2734    Splitter1: TSplitter;
    2835    StatusBar1: TStatusBar;
    2936    TreeView1: TTreeView;
     37    procedure AValueAddExecute(Sender: TObject);
    3038    procedure FormShow(Sender: TObject);
    3139    procedure ListView1Data(Sender: TObject; Item: TListItem);
     
    3341    function RegValueToString(Name: string): string;
    3442    procedure LoadNode(Node: TTreeNode; Key: TRegKey);
     43    procedure ReloadTreeNode(Node: TTreeNode; Reg: TGeneralRegistry);
    3544  public
    3645    procedure ReloadValues;
     
    7584  ReloadKeys;
    7685  ReloadValues;
     86end;
     87
     88procedure TFormMain.AValueAddExecute(Sender: TObject);
     89begin
     90//  Core.ActiveRegistry.Write;
    7791end;
    7892
     
    120134end;
    121135
     136procedure TFormMain.ReloadTreeNode(Node: TTreeNode; Reg: TGeneralRegistry);
     137var
     138  Keys: TStrings;
     139  I: Integer;
     140  NewNode: TTreeNode;
     141begin
     142  Keys := TStringList.Create;
     143  Reg.GetKeyNames(Keys);
     144  for I := 0 to Keys.Count - 1 do begin
     145    NewNode := Node.TreeNodes.AddChild(Node, Keys[I]);
     146    Reg.OpenKey(Keys[I], False);
     147    ReloadTreeNode(NewNode, Reg);
     148  end;
     149  Keys.Free;
     150end;
     151
    122152procedure TFormMain.ReloadKeys;
    123153var
    124154  NewNode: TTreeNode;
    125155begin
     156  TreeView1.Items.Clear;
    126157  NewNode := TreeView1.Items.AddChild(nil, 'Local computer');
     158  ReloadTreeNode(NewNode, Core.ActiveRegistry);
     159  NewNode.Expand(True);
    127160end;
    128161
  • Registry/GeneralRegistry.lpk

    r408 r538  
    1 <?xml version="1.0"?>
     1<?xml version="1.0" encoding="UTF-8"?>
    22<CONFIG>
    33  <Package Version="4">
    44    <Name Value="GeneralRegistry"/>
     5    <Type Value="RunAndDesignTime"/>
    56    <Author Value="Chronos (robie@centrum.cz)"/>
    67    <CompilerOptions>
     
    910        <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
    1011      </SearchPaths>
    11       <Other>
    12         <CompilerMessages>
    13           <MsgFileName Value=""/>
    14         </CompilerMessages>
    15         <CompilerPath Value="$(CompPath)"/>
    16       </Other>
    1712    </CompilerOptions>
    1813    <Description Value="Generalized registry classes for multiplatform programming."/>
    1914    <License Value="LGPL"/>
    2015    <Version Minor="1"/>
    21     <Files Count="4">
    22       <Item1>
    23         <Filename Value="WinRegistry.pas"/>
    24         <Type Value="Text"/>
    25         <UnitName Value="WinRegistry"/>
    26       </Item1>
    27       <Item3>
     16    <Files Count="2">
     17      <Item2>
    2818        <Filename Value="UGeneralRegistry.pas"/>
    2919        <HasRegisterProc Value="True"/>
    3020        <UnitName Value="UGeneralRegistry"/>
    31       </Item3>
    32       <Item4>
    33         <Filename Value="UTest.pas"/>
    34         <UnitName Value="UTest"/>
    35       </Item4>
     21      </Item2>
    3622    </Files>
    37     <Type Value="RunAndDesignTime"/>
    3823    <RequiredPkgs Count="1">
    3924      <Item1>
  • Registry/GeneralRegistry.pas

    r408 r538  
    55unit GeneralRegistry;
    66
     7{$warn 5023 off : no warning about unused units}
    78interface
    89
    910uses
    10   UGeneralRegistry, UTest, LazarusPackageIntf;
     11  UGeneralRegistry, LazarusPackageIntf;
    1112
    1213implementation
  • Registry/UGeneralRegistry.pas

    r392 r538  
    66
    77uses
    8   Classes, SysUtils, IniFiles, XMLRead, XMLWrite, DOM
    9   {$IFDEF Windows}
    10   , WinRegistry
    11   {$ENDIF};
     8  Classes, SysUtils, IniFiles, XMLRead, XMLWrite, DOM, Registry;
    129
    1310type
     
    246243function TWinRegistry.GetKeyInfo(var Value: TRegKeyInfo): Boolean;
    247244var
    248   KeyInfo: WinRegistry.TRegKeyInfo;
     245  KeyInfo: Registry.TRegKeyInfo;
    249246begin
    250247  Result := Registry.GetKeyInfo(KeyInfo);
     
    262259function TWinRegistry.GetValueInfo(const Name: string; var Value: TRegValueInfo): Boolean;
    263260var
    264   ValueInfo: WinRegistry.TRegDataInfo;
     261  ValueInfo: Registry.TRegDataInfo;
    265262begin
    266263  Result := Registry.GetDataInfo(Name, ValueInfo);
     
    399396
    400397procedure TWinRegistry.GetKeyNames(Strings: TStrings);
     398var
     399  I: Integer;
    401400begin
    402401  Registry.GetKeyNames(Strings);
     402//  for I := 0 to Strings.Count - 1 do
     403//    Strings[I] := AnsiToUtf8(Strings[I]);
    403404end;
    404405
     
    687688  {$IFDEF Windows}
    688689  Backend := TWinRegistry.Create;
    689   //TWinRegistry(Backend).RootKey := HKEY_CURRENT_USER;
    690   //TWinRegistry(Backend).BaseKey := 'Software\' + CompanyName + '\' +
    691   //  ApplicationName;
     690  TWinRegistry(Backend).CurrentRoot := HKEY_CURRENT_USER;
     691  TWinRegistry(Backend).CurrentKey := 'Software\Company\' +
     692    ApplicationName;
     693//  TWinRegistry(Backend).CurrentKey := 'Software\' + VendorName + '\' +
     694//    ApplicationName;
    692695  {$ENDIF}
    693696  {$IFDEF Linux}
Note: See TracChangeset for help on using the changeset viewer.