Changeset 12 for trunk/UCore.pas
- Timestamp:
- Nov 15, 2012, 8:06:57 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r7 r12 7 7 uses 8 8 Registry, Classes, SysUtils, FileUtil, USqlDatabase, URegistry, Forms, 9 UApplicationInfo, UCoolTranslator, UPersistentForm; 9 UApplicationInfo, UCoolTranslator, UPersistentForm, UModularSystem, 10 UFormModuleList; 10 11 11 12 type … … 17 18 CoolTranslator1: TCoolTranslator; 18 19 Database: TSqlDatabase; 20 ModuleManager: TModuleManager; 19 21 procedure DataModuleCreate(Sender: TObject); 20 22 procedure DataModuleDestroy(Sender: TObject); 23 procedure ModuleManagerUpdate(Sender: TObject); 21 24 private 25 procedure ModuleManagerChange(Sender: TObject); 22 26 public 27 FormModuleList: TFormModuleList; 23 28 FormList: TForm; 24 29 PersistentForm: TPersistentForm; 30 RegistryContext: TRegistryContext; 25 31 procedure Init; 26 32 procedure Done; 27 33 procedure InitData; 28 34 procedure Connect; 29 procedure LoadFromRegistry( Context: TRegistryContext);30 procedure SaveToRegistry( Context: TRegistryContext);35 procedure LoadFromRegistry(AContext: TRegistryContext); 36 procedure SaveToRegistry(AContext: TRegistryContext); 31 37 end; 32 38 … … 38 44 {$R *.lfm} 39 45 46 uses 47 URegistredModules; 48 40 49 41 50 { TCore } … … 46 55 PersistentForm.RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot), 47 56 ApplicationInfo1.RegistryKey + '\Forms'); 57 ModuleManager := TModuleManager.Create(nil); 58 RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey); 48 59 end; 49 60 50 61 procedure TCore.DataModuleDestroy(Sender: TObject); 51 62 begin 63 if Assigned(FormModuleList) then FreeAndNil(FormModuleList); 64 FreeAndNil(ModuleManager); 52 65 FreeAndNil(PersistentForm); 66 end; 67 68 procedure TCore.ModuleManagerUpdate(Sender: TObject); 69 begin 70 if Assigned(FormModuleList) then 71 FormModuleList.Reload; 72 end; 73 74 procedure TCore.ModuleManagerChange(Sender: TObject); 75 begin 76 53 77 end; 54 78 55 79 procedure TCore.Init; 56 80 begin 57 LoadFromRegistry(RegContext(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey)); 58 // LoadFromRegistry(RegContext(HKEY_CURRENT_USER, '\Software\Chronosoft\Dochazka')); 81 LoadFromRegistry(RegistryContext); 59 82 60 Connect; 83 // Init modules 84 with TRegistryEx.Create do 85 try 86 Context := RegistryContext; 87 RegisterModules(ModuleManager); 88 if ReadBoolWithDefault('ModuleManagerInstalled', False) then 89 ModuleManager.LoadFromRegistry(RegContext(RegistryContext.RootKey, RegistryContext.Key + '\Modules')) 90 else begin 91 ModuleManager.Modules.Perform([maEnable]); 92 ModuleManager.SaveToRegistry(RegContext(RegistryContext.RootKey, RegistryContext.Key + '\Modules')); 93 WriteBool('ModuleManagerInstalled', True); 94 end; 95 finally 96 Free; 97 end; 98 ModuleManager.Modules.Perform([maStart], [mcEnabled]); 99 100 Connect; 61 101 end; 62 102 63 103 procedure TCore.Done; 64 104 begin 65 SaveToRegistry(Reg Context(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey));105 SaveToRegistry(RegistryContext); 66 106 end; 67 107 … … 83 123 end; 84 124 85 procedure TCore.LoadFromRegistry( Context: TRegistryContext);125 procedure TCore.LoadFromRegistry(AContext: TRegistryContext); 86 126 begin 87 127 with TRegistryEx.Create do 88 128 try 89 RootKey := Context.RootKey; 90 OpenKey('\Software\Chronosoft\Dochazka', True); 91 //OpenKey(Context.Key, True); 129 Context := AContext; 92 130 Database.HostName := ReadStringWithDefault('HostName', 'localhost'); 93 131 Database.Database := ReadStringWithDefault('Schema', 'dochazka'); … … 100 138 end; 101 139 102 procedure TCore.SaveToRegistry( Context: TRegistryContext);140 procedure TCore.SaveToRegistry(AContext: TRegistryContext); 103 141 begin 104 142 with TRegistryEx.Create do 105 143 try 106 RootKey := Context.RootKey; 107 OpenKey(Context.Key, True); 144 Context := AContext; 108 145 WriteString('HostName', Database.HostName); 109 146 WriteString('Schema', Database.Database);
Note:
See TracChangeset
for help on using the changeset viewer.