Application utilities

Commands for various Windows application utilities

SYNOPSIS

package require twapi_apputil
delete_inifile_key SECTION KEY ?-inifile FILENAME?
delete_inifile_section SECTION ?-inifile FILENAME?
get_command_line
get_command_line_args COMMANDLINE
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 commonly required in Windows applications.

Application command line

The following commands relate to the command line for the process. The difference over Tcl's built-in ::argv variables is that these commands handle Unicode command lines and use Windows conventions for argument parsing.

get_command_line Retrieves the command line passed to the process.
get_command_line_args Parses a command line using Windows conventions.

For retrieving the command line for another process, see get_process_info in the twapi_process module.

INI files

The following commands deal with INI files used for storing application preferences. 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.

read_inifile_key Returns the value of a key.
write_inifile_key Updates the value of a key.
delete_inifile_key Deletes a key and associated value.
read_inifile_section_names Returns the names of all sections in an INI file.
read_inifile_section Returns the keys and values within a INI file section.
delete_inifile_section Deletes an entire section from an INI file.

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.
get_command_line
Returns the command line of the current process. This may be passed to the get_command_line_args function to split the line into arguments.
get_command_line_args COMMANDLINE
Parses COMMANDLINE as per Windows command line conventions and returns a list of the parsed arguments. The main advantage of this over using the argv and argv0 variables in tclsh and wish is that this call will correctly handle Unicode arguments.
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-2012, Ashok P. Nadkarni

Tcl Windows API 5.0