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.
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}
function TppDevRegistry.CreateCustomIniFile(aStorageName: String): TCustomIniFile; var TempRegFile: TRegistryIniFile; begin TempRegFile := TRegistryIniFile.Create(aStorageName); TempRegFile.RegIniFile.RootKey := SystemRegistryKey; Result := TempRegFile; end; {function, CreateCustomIniFile}
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.
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;
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.
Comments
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
http://www.digital-metaphors.com
info@digital-metaphors.com
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.
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
http://www.digital-metaphors.com
info@digital-metaphors.com
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;
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
http://www.digital-metaphors.com
info@digital-metaphors.com
HKEY_LOCAL_MACHINE\Software...