Home > Back-end >  How Delphi in existing ini file, to continue to write the content (not delete the contents of the or
How Delphi in existing ini file, to continue to write the content (not delete the contents of the or

Time:11-12

How Delphi in existing ini file, to continue to write the content (not delete the contents of the original)

CodePudding user response:

Cover is not to build itself is to read and write

CodePudding user response:

Var
TextFileVar: Text;
.
AssignFile: put an external file name associated with a file variable

Reset: open an existing file

Rewrite: create and open a new file (or override the original file)

Append: to add a way to open a file (only applicable to a text file)

CloseFile: close an open file

FileOpen: open a specific file and returns a file handle

FileCreate: create a file of a given file name and returns the file handle

FileClose: close the handle to a specific file

Three files mainly for the use of internal system, back in the programming of copying files also tend to be used, their operation object is a file handle rather than a file variable



Or
Var
LST: Tstringlist;
The begin
LST:=tstringlist. Create;
LST. LoadFromFile ();
LST. Append (' A=b);
LST. SaveToFile ();
end;

CodePudding user response:

TIniFile this class is in view of the ini file

CodePudding user response:

F:=tinifile. Create (path + '\ config ini');
F.W riteString (' LinkInfo ', 'Server' s);
F.F ree;

CodePudding user response:

Ini cut a talk about the

[CSYQ]
UserID=9 cc2c196 - C6D6-49 Ed - 962 - e - 6 a98fef9a4e2
DBAcc=CSYQ
ClientWidth=Max
The Header=1

REG_SECTION:='CSYQ';//as long as the node name is different, you can add in the original ini

GV_IniFileName:=ExtractFilePath (Application. ExeName) + 'Config. Ini';
GV_IniFile:=TIniFile. Create (GV_IniFileName);

If not GV_IniFile. SectionExists (REG_SECTION) then//judge you want to add nodes in not
The begin
GV_IniFile. WriteInteger (REG_SECTION, 'ClientWidth', the Self. ClientWidth);
GV_IniFile. WriteInteger (REG_SECTION, 'ClientHeight', the Self. ClientHeight);
end;

CodePudding user response:

reference 4 floor nongen response:
: f=tinifile. Create (path + '\ config ini');
F.W riteString (' LinkInfo ', 'Server' s);
F.F ree;


Positive solution
  • Related