| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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.
|