Changeset 25 for trunk/UCore.pas


Ignore:
Timestamp:
Nov 9, 2011, 1:58:00 PM (13 years ago)
Author:
george
Message:
  • Modified: Login form now use connection profile form for selecting connection parameters.
  • Added: About application dialog.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r15 r25  
    66
    77uses
    8   Classes, SysUtils, FileUtil, UCoolTranslator, UDebugLog, USystem,
    9   USqlDatabase;
     8  Classes, SysUtils, FileUtil, UCoolTranslator, UDebugLog, USystem, Registry,
     9  USqlDatabase, ULoginProfileForm, URegistry;
    1010
    1111type
     
    2121    procedure SqlDatabase1LogQuery(Sender: TObject; Text: string);
    2222  private
     23    procedure LoadFromRegistry;
     24    procedure SaveToRegistry;
    2325    { private declarations }
    2426  public
     27    LastUserName: string;
     28    LastProfile: Integer;
     29    LastPassword: string;
     30    Profiles: TProfileList;
     31    RegistryKey: string;
     32    RegistryRootKey: HKEY;
    2533    System: TChronisBase;
    2634  end;
     
    3341{$R *.lfm}
    3442
     43uses
     44  UApplicationInfo;
     45
    3546{ TCore }
    3647
    3748procedure TCore.DataModuleCreate(Sender: TObject);
    3849begin
     50  Profiles := TProfileList.Create;
     51  RegistryRootKey := HKEY_CURRENT_USER;
     52  RegistryKey := '\Software\' + ApplicationInfo.CompanyName + '\' +
     53    ApplicationInfo.Name;
     54  LoadFromRegistry;
    3955  System := TChronisBase.Create;
    4056  System.Database := SqlDatabase1;
     
    4662procedure TCore.DataModuleDestroy(Sender: TObject);
    4763begin
     64  SaveToRegistry;
    4865  System.Free;
     66  Profiles.Free;
    4967end;
    5068
     
    5472end;
    5573
     74procedure TCore.LoadFromRegistry;
     75begin
     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;
     85end;
     86
     87procedure TCore.SaveToRegistry;
     88begin
     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;
     98end;
     99
     100
    56101end.
    57102
Note: See TracChangeset for help on using the changeset viewer.