unit AppCentreINI; interface uses Classes, SysUtils, IniFiles, Forms, Windows; const csIniAppCentreSection = 'AppCentre'; {Section: AppCentre} csIniAppCentreAppKey = 'AppKey'; csIniAppCentreAppSecret = 'AppSecret'; type TIniOptions = class(TObject) private {Section: AppCentre} FAppCentreAppKey: string; FAppCentreAppSecret: string; public procedure LoadSettings(Ini: TIniFile); procedure SaveSettings(Ini: TIniFile); procedure LoadFromFile(const FileName: string); procedure SaveToFile(const FileName: string); {Section: AppCentre} property AppCentreAppKey: string read FAppCentreAppKey write FAppCentreAppKey; property AppCentreAppSecret: string read FAppCentreAppSecret write FAppCentreAppSecret; end; var IniOptions: TIniOptions = nil; implementation procedure TIniOptions.LoadSettings(Ini: TIniFile); begin if Ini <> nil then begin {Section: AppCentre} FAppCentreAppKey := Ini.ReadString(csIniAppCentreSection, csIniAppCentreAppKey, 'ddddd'); FAppCentreAppSecret := Ini.ReadString(csIniAppCentreSection, csIniAppCentreAppSecret, 'ddddd'); end; end; procedure TIniOptions.SaveSettings(Ini: TIniFile); begin if Ini <> nil then begin {Section: AppCentre} Ini.WriteString(csIniAppCentreSection, csIniAppCentreAppKey, FAppCentreAppKey); end; end; procedure TIniOptions.LoadFromFile(const FileName: string); var Ini: TIniFile; begin Ini := TIniFile.Create(FileName); try LoadSettings(Ini); finally Ini.Free; end; end; procedure TIniOptions.SaveToFile(const FileName: string); var Ini: TIniFile; begin Ini := TIniFile.Create(FileName); try SaveSettings(Ini); finally Ini.Free; end; end; initialization IniOptions := TIniOptions.Create; finalization IniOptions.Free; end.