Ignore:
Timestamp:
Dec 19, 2011, 12:58:50 PM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Načítání nastavení z registrů nahrazeno INI souborem.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        22bin
        33lib
         4Config.ini
  • trunk/Modules/UMainModule.pas

    r62 r63  
    77uses
    88  Classes, SysUtils, FileUtil, LResources, UHTTPServerCGI, UHTTPSessionMySQL,
    9   UHTTPServer, USqlDatabase, URegistry, DateUtils, UWebPage, UWebApp,
     9  UHTTPServer, USqlDatabase, INIFiles, DateUtils, UWebPage, UWebApp,
    1010  UXmlClasses, UHtmlClasses, UCore, UHTTPServerTCP,
    1111  UHTTPSessionFile, UUser, SpecializedList, Registry;
     12
     13const
     14  ConfigFile = 'Config.ini';
    1215
    1316type
     
    115118  UserOnline := TWebOnlineUser.Create;
    116119  UserOnline.Database := Database;
     120  LoadFromRegistry;
    117121end;
    118122
    119123destructor TMainModule.Destroy;
    120124begin
     125  SaveToRegistry;
    121126  HtmlDocument.Free;
    122127  User.Free;
     
    229234
    230235procedure TMainModule.LoadFromRegistry;
    231 begin
    232   with TRegistryEx.Create do
     236const
     237  SectionGeneral = 'General';
     238  SectionDatabase = 'Database';
     239begin
     240  with TIniFile.Create(ConfigFile) do
    233241  try
    234     RootKey := HKEY_CURRENT_USER;
    235     OpenKey(ApplicationInfo.RegistryKey, True);
    236     Style := ReadStringWithDefault('Style', 'Basic');
    237     BaseURL := ReadStringWithDefault('BaseURL', 'http://localhost');
    238     Database.Hostname := ReadStringWithDefault('DatabaseHostName', 'localhost');
    239     Database.Database := ReadStringWithDefault('DatabaseDatabase', 'web');
    240     Database.UserName := ReadStringWithDefault('DatabaseUserName', 'user');
    241     Database.Password := ReadStringWithDefault('DatabasePassword', 'password');
    242     FormatHTML := ReadBoolWithDefault('FormatHTML', False);
    243     Application.LogException := not ReadBoolWithDefault('ShowException', False);
     242    //RootKey := HKEY_CURRENT_USER;
     243    //OpenKey(ApplicationInfo.RegistryKey, True);
     244    Style := ReadString(SectionGeneral, 'Style', 'Basic');
     245    BaseURL := ReadString(SectionGeneral, 'BaseURL', 'http://localhost');
     246    Database.Hostname := ReadString(SectionDatabase, 'DatabaseHostName', 'localhost');
     247    Database.Database := ReadString(SectionDatabase, 'DatabaseDatabase', 'web');
     248    Database.UserName := ReadString(SectionDatabase, 'DatabaseUserName', 'user');
     249    Database.Password := ReadString(SectionDatabase, 'DatabasePassword', 'password');
     250    FormatHTML := ReadBool(SectionGeneral, 'FormatHTML', False);
     251    Application.LogException := not ReadBool(SectionGeneral, 'ShowException', False);
    244252  finally
    245253    Free;
     
    248256
    249257procedure TMainModule.SaveToRegistry;
    250 begin
    251 
     258const
     259  SectionGeneral = 'General';
     260  SectionDatabase = 'Database';
     261begin
     262  with TIniFile.Create(ConfigFile) do
     263  try
     264    //RootKey := HKEY_CURRENT_USER;
     265    //OpenKey(ApplicationInfo.RegistryKey, True);
     266    WriteString(SectionGeneral, 'Style', Style);
     267    WriteString(SectionGeneral, 'BaseURL', BaseURL);
     268    WriteString(SectionDatabase, 'DatabaseHostName', Database.Hostname);
     269    WriteString(SectionDatabase, 'DatabaseDatabase', Database.Database);
     270    WriteString(SectionDatabase, 'DatabaseUserName', Database.UserName);
     271    WriteString(SectionDatabase, 'DatabasePassword', Database.Password);
     272    WriteBool(SectionGeneral, 'FormatHTML', FormatHTML);
     273    WriteBool(SectionGeneral, 'ShowException', not Application.LogException);
     274  finally
     275    Free;
     276  end;
    252277end;
    253278
    254279procedure TMainModule.Run;
    255280begin
    256   LoadFromRegistry;
    257281  InitDatabase;
    258282  //Database.Query('SELECT * FROM ssss');
Note: See TracChangeset for help on using the changeset viewer.