unit CfgParams; interface uses Classes, SysUtils; const cfgName = 'cfgPort.txt'; type TScCfgPort = class private FPort: Integer; FIP: string; FFileDir: string; FPortStr: TStringList; public constructor Create; destructor Destroy; override; procedure ReadPort; procedure WritePort; property Port: Integer read FPort write FPort; property IP: string read FIP write FIP; property FileDir: string read FFileDir write FFileDir; end; implementation { TScCfgPort } constructor TScCfgPort.Create; begin FPortStr := TStringList.Create; end; destructor TScCfgPort.Destroy; begin FPortStr.Free; inherited; end; procedure TScCfgPort.ReadPort; begin if FileExists(FFileDir + cfgName) then FPortStr.LoadFromFile(FFileDir + cfgName) else Exit; if FPortStr.Count > 0 then begin FPort := StrToInt(FPortStr.Strings[0]); FIP := FPortStr.Strings[1]; end; end; procedure TScCfgPort.WritePort; begin FPortStr.Clear; FPortStr.Add(IntToStr(FPort)); FPortStr.Add(FIP); FPortStr.SaveToFile(FFileDir + cfgName); end; end.