Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Registry Settings

edited March 2002 in General
How do I save my registry settings in HKEY_CURRENT_MACHINE instead of
HKEY_CURRENT_USER.

Comments

  • edited March 2002
    You can create your own TppRegistry descendent and override the
    CreateCustomIniFile method to assign the desired registry key to the
    RegIniFile.RootKey property of the TRegistryIniFile object. The source for
    the implementation of TppRegistry is found in
    RBuilder/Source/ppIniStorage.pas.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited March 2002
    The following code compiles but the origional code is still being used.
    What am I missing?

    unit UnitDevRWIniStorage;

    interface

    uses inifiles, ppIniStorage, proreg, registry;

    type
    TppDevRegistry = class(TppRegistry)
    protected
    function CreateCustomIniFile(aStorageName: String):
    TCustomIniFile; override;
    public
    class function ClassDescription: String; override;
    class function DefaultStorageName: String; override;
    end; {class, TppdevRegistry}

    implementation

    {------------------------------------------------------------------------------}
    { TppdevRegistry.CreateCustomIniFile }

    function TppDevRegistry.CreateCustomIniFile(aStorageName: String):
    TCustomIniFile;
    var
    TempRegFile: TRegistryIniFile;
    begin
    TempRegFile := TRegistryIniFile.Create(aStorageName);
    TempRegFile.RegIniFile.RootKey := SystemRegistryKey;
    Result := TempRegFile;
    end; {function, CreateCustomIniFile}

    {------------------------------------------------------------------------------}
    { TppdevRegistry.Description }

    class function TppDevRegistry.ClassDescription: String;
    begin
    Result := 'DevRegistry';
    end; {class function, Description}

    class function TppDevRegistry.DefaultStorageName: String;
    begin
    Result := 'RBuilder';

    end; {class function, DefaultStorageName}

    initialization

    TppIniStoragePlugIns.Register(TppDevRegistry);

    finalization

    TppIniStoragePlugIns.UnRegister(TppDevRegistry);

    end.

  • edited March 2002
    Make sure that you set the Designer's IniStorageType property to the name of
    your new storage class, in this case DevRegistry. You have to do this at
    runtime before showing the designer because, since TppDevRegistry isn't
    installed at design time, the object inspector will default to Registry when
    the project is compiled.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited April 2002
    I've added the name of the new storage class name to the FormCreate
    event of my main Report Writer application which contains ppDesigner but
    the key is still being created in the HKEY_CURRENT_USER instead of
    HKEY_LOCAL_MACHINE.

    procedure TFormDSReportWriter.FormCreate(Sender: TObject);
    begin
    inherited;

    Height := 83;
    FNewReport := False;
    FUpdatingRunDate := False;
    FNewFolder := False;
    ppReportExplorer.OnRunReport := RunReport;
    ppReport.Template.OnNew := NewReport;


    UpdateFolderReportsLiveResults;


    UpdateDatabaseType;

    FReg := TProReg.Create;
    ReadRegistrySettings;
    AnimateWait.Active := True;

    ppDesigner.IniStorageType := 'DevRegistry';

    end;

  • edited April 2002
    Here's is a demo of an inherited Registry class that writes to
    HKEY_LOCAL_MACHINE. Keep in mind that you cannot create keys directly under
    HKEY_LOCAL_MACHINE. This example creates the RBuilder key under
    HKEY_LOCAL_MACHINE\Software.

    www.digital-metaphors.com\tips\RegistryAlternateKeys.zip

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited April 2002
    This link could not be found. I am creating the key under
    HKEY_LOCAL_MACHINE\Software...


This discussion has been closed.