RTL.IniFileStorage Sample

From Appmethod Code Examples
Jump to: navigation, search

IniFileStorage is a sample unit that implements a subclass of TTetheringCustomStorage that provides persistence for TTetheringManager pairing information using an INI file.


You can find the IniFileStorage unit at:


You can use this sample unit in your tethering-enabled applications to provide persistence for pairing information to your application.

How to Use the Sample

  1. Create a tethering-enabled application. See Adding App Tethering to Your Application.
  2. Copy the sample unit from the location provided above into your project folder. For example, save it to Template:ProjectsPath\MyProject\System.Tether.IniFileStorage.pas.
  3. On the Project Manager, right-click your project entry, select Add, and select the copy of the sample unit from your project folder.
  4. In the unit of your project that contains the TTetheringManager component:
    1. Add a reference to the System.Tether.IniFileStorage unit.
    2. Select your TTetheringManager component and, on the Object Inspector, double-click the OnRequestStorage event.
    3. Implement its event handler as follows:
AStorage := TTetheringIniFileStorage.Create(TPath.GetDocumentsPath + PathDelim + 'file.ini');
  • The path to the INI file in the code above is just an example.
  • To use system path functions such as GetDocumentsPath, include a reference to the System.IOUtils unit in your code.

Your TTetheringManager component now persists its data to the specified INI file. For more information, see TTetheringCustomStorage.


The file name of the sample unit is System.Tether.IniFileStorage.pas.


The sample unit defines a subclass or TTetheringCustomStorage: TTetheringIniFileStorage.


TTetheringIniFileStorage implements the methods of its parent class TTetheringCustomStorage using System.IniFiles.TIniFile to create and update the INI file where TTetheringIniFileStorage persists the data from the TTetheringManager component.


See Also