12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- unit CfgPort;
- 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;
- property Port: Integer read FPort;
- property IP: string read 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;
- end.
|