Changeset 25 for trunk/UCore.pas
- Timestamp:
- Nov 9, 2011, 1:58:00 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r15 r25 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UCoolTranslator, UDebugLog, USystem, 9 USqlDatabase ;8 Classes, SysUtils, FileUtil, UCoolTranslator, UDebugLog, USystem, Registry, 9 USqlDatabase, ULoginProfileForm, URegistry; 10 10 11 11 type … … 21 21 procedure SqlDatabase1LogQuery(Sender: TObject; Text: string); 22 22 private 23 procedure LoadFromRegistry; 24 procedure SaveToRegistry; 23 25 { private declarations } 24 26 public 27 LastUserName: string; 28 LastProfile: Integer; 29 LastPassword: string; 30 Profiles: TProfileList; 31 RegistryKey: string; 32 RegistryRootKey: HKEY; 25 33 System: TChronisBase; 26 34 end; … … 33 41 {$R *.lfm} 34 42 43 uses 44 UApplicationInfo; 45 35 46 { TCore } 36 47 37 48 procedure TCore.DataModuleCreate(Sender: TObject); 38 49 begin 50 Profiles := TProfileList.Create; 51 RegistryRootKey := HKEY_CURRENT_USER; 52 RegistryKey := '\Software\' + ApplicationInfo.CompanyName + '\' + 53 ApplicationInfo.Name; 54 LoadFromRegistry; 39 55 System := TChronisBase.Create; 40 56 System.Database := SqlDatabase1; … … 46 62 procedure TCore.DataModuleDestroy(Sender: TObject); 47 63 begin 64 SaveToRegistry; 48 65 System.Free; 66 Profiles.Free; 49 67 end; 50 68 … … 54 72 end; 55 73 74 procedure TCore.LoadFromRegistry; 75 begin 76 with TRegistryEx.Create do 77 try 78 RootKey := RegistryRootKey; 79 OpenKey(RegistryKey, True); 80 LastProfile := ReadIntegerWithDefault('LastConnectProfile', -1); 81 LastUserName := ReadStringWithDefault('LastUserName', 'admin'); 82 finally 83 Free; 84 end; 85 end; 86 87 procedure TCore.SaveToRegistry; 88 begin 89 with TRegistryEx.Create do 90 try 91 RootKey := RegistryRootKey; 92 OpenKey(RegistryKey, True); 93 WriteInteger('LastConnectProfile', LastProfile); 94 WriteString('LastUserName', LastUserName); 95 finally 96 Free; 97 end; 98 end; 99 100 56 101 end. 57 102
Note:
See TracChangeset
for help on using the changeset viewer.