INI File - Accessing INI Files

Accessing INI Files

Under Windows, the Profile API is the programming interface used to read and write settings from classic Windows .ini files. For example, the GetPrivateProfileString function retrieves a string from the specified section in an initialization file.

The following sample C program demonstrates reading property values from the above sample INI file (Let the name of configuration file be dbsettings.ini)

#include int main(int argc, _TCHAR *argv) { _TCHAR dbserver; int dbport; GetPrivateProfileString("database", "server", "127.0.0.1", dbserver, 1000, "dbsettings.ini"); dbport = GetPrivateProfileInt("database", "port", 143, "dbsettings.ini"); // N.B. WritePrivateProfileInt does not exist return 0; }

Python's standard library provides the configparser module for parsing INI-like configuration files.

Read more about this topic:  INI File

Famous quotes containing the word files:

    Here files of pins extend their shining rows,
    Puffs, powders, patches, bibles, billet-doux.
    Alexander Pope (1688–1744)