CfgPort.pas 890 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. unit CfgPort;
  2. interface
  3. uses Classes, SysUtils;
  4. const
  5. cfgName = 'cfgPort.txt';
  6. type
  7. TScCfgPort = class
  8. private
  9. FPort: Integer;
  10. FIP: string;
  11. FFileDir: string;
  12. FPortStr: TStringList;
  13. public
  14. constructor Create;
  15. destructor Destroy; override;
  16. procedure ReadPort;
  17. property Port: Integer read FPort;
  18. property IP: string read FIP;
  19. property FileDir: string read FFileDir write FFileDir;
  20. end;
  21. implementation
  22. { TScCfgPort }
  23. constructor TScCfgPort.Create;
  24. begin
  25. FPortStr := TStringList.Create;
  26. end;
  27. destructor TScCfgPort.Destroy;
  28. begin
  29. FPortStr.Free;
  30. inherited;
  31. end;
  32. procedure TScCfgPort.ReadPort;
  33. begin
  34. if FileExists(FFileDir + cfgName) then
  35. FPortStr.LoadFromFile(FFileDir + cfgName)
  36. else Exit;
  37. if FPortStr.Count > 0 then
  38. begin
  39. FPort := StrToInt(FPortStr.Strings[0]);
  40. FIP := FPortStr.Strings[1];
  41. end;
  42. end;
  43. end.