Application utilities
Commands for various Windows application utilities
package require
twapi_apputil
This module provides commands commonly required in Windows
applications.
get_command_line
retrieves the command line passed to the process. get_command_line_args parses a command line using
Windows conventions. The difference over Tcl's built-in
::argv variables is that these commands
handle Unicode command lines and use Windows conventions for
argument parsing.
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.
- 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 © 2004-2012, Ashok P. Nadkarni