Windows INI file

Commands for accessing Windows INI files

SYNOPSIS

package require twapi
delete_inifile_key SECTION KEY ?-inifile FILENAME?
delete_inifile_section SECTION ?-inifile FILENAME?
read_inifile_key SECTION KEY ?options?
read_inifile_section SECTION ?-inifile FILENAME?
read_inifile_section_names ?-inifile FILENAME?
write_inifile_key SECTION KEY VALUE ?-inifile FILENAME?

DESCRIPTION

This module provides commands to access Windows INI files

Overview

These commands are wrappers to the Windows functions that provide access to INI files such as GetPrivateProfileString.

The commands read_inifile_key, write_inifile_key and delete_inifile_key can be used for manipulating individual entries.

The commands read_inifile_section_names, read_inifile_section and delete_inifile_section may be used for manipulating entire sections of INI files.

Note these commands take into account INI file mappings set up in the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping registry key.

A cross-platform package that provides similar functionality is available in the available in the tcllib standard library. However, that does not take into account the registry mappings on Windows platforms.

Commands

delete_inifile_key SECTION KEY ?-inifile FILENAME?
Deletes the key KEY from the INI file section SECTION. By default, the command writes to the win.ini file in the system directory. The -inifile option may be used to specify different INI file.
delete_inifile_section SECTION ?-inifile FILENAME?
Deletes the entire section SECTION from an INI file. By default, the command writes to the win.ini file in the system directory. The -inifile option may be used to specify a different INI file.
read_inifile_key SECTION KEY ?options?
Returns the value of the key KEY in the INI file section SECTION. If the key is not found, an empty string is returned unless the -default option is specified. The following options may be specified:
-default DEFAULTVALUE If the key is not found in the section, the command returns DEFAULTVALUE instead of an empty string.
-inifile FILENAME By default, the command looks up the win.ini file in the system directory. This option may be used to look up a different INI file instead.
read_inifile_section SECTION ?-inifile FILENAME?
Returns all the entries in section SECTION of an INI file as a list of key value pairs. By default, the command reads the win.ini file in the system directory. The -inifile option may be used to specify a different INI file.
read_inifile_section_names ?-inifile FILENAME?
Returns the names of all sections in an INI file. By default, the command reads the win.ini file in the system directory. The -inifile option may be used to specify a different INI file.
write_inifile_key SECTION KEY VALUE ?-inifile FILENAME?
Writes VALUE as the value of the key KEY in the INI file section SECTION. The section and key are created if they did not already exist. By default, the command writes to the win.ini file in the system directory. The -inifile option may be used to look up a different INI file instead.

COPYRIGHT

Copyright © 2004, Ashok P. Nadkarni

Tcl Windows API 2.1.6 Privacy policy