Windows Shell

Windows shell commands

SYNOPSIS

package require twapi
get_shell_folder CSIDL ?-create?
CloseThemeData
GetCurrentThemeName
GetThemeColor
GetThemeFont
invoke_url_shortcut SHORTCUTPATH ?options?
IsAppThemed
IsThemeActive
OpenThemeData
read_shortcut SHORTCUTPATH ?options?
read_url_shortcut SHORTCUTPATH
recycle_file FILENAME ?-confirm BOOLEAN? ?-showerror BOOLEAN?
shell_object_properties_dialog OBJECTPATH ?options?
write_shortcut SHORTCUTPATH ?options?
write_url_shortcut SHORTCUTPATH URL ?-missingprotocol usedefault|guess?

DESCRIPTION

This module provides procedures related to the Windows shell.

Item Identifiers

The Windows shell identifies objects in its namespace, including non-file objects such as Control Panel applets and printers, using an item ID. Similar to a file system path, an object resides within the shell namespace object hierarchy and the entire path to the object is defined by item identifier list.

Folder Paths

The command get_shell_folder returns the path to the directory specified by a Windows Shell CSIDL.

File Operations

The command recycle_file sends the specified file to the Windows Recycle Bin.

Shell Dialogs

The command shell_object_properties_dialog displays the property page dialogs for the specified shell objects.

Themes

The commands OpenThemeData, CloseThemeData, IsThemeActive, IsAppThemed, GetCurrentThemeName, GetThemeColor and GetThemeFont provide access to information related to the current theme if the underlying platform supports themes. See the Windows SDK for documentation about these. TwapiThemeDefineValue is a utility function that translates various theme-related symbols described in the SDk to their integer values to be passed to the above functions.

Shortcuts

The commands read_shortcut and write_shortcut allow reading and writing of shell shortcuts.

The commands read_url_shortcut and write_url_shortcut allow reading and writing of URL shortcuts. A URL shortcut can be invoked by invoke_url_shortcut.

Commands

get_shell_folder CSIDL ?-create?
Returns the path to the file system directory corresponding to the Windows shell folder identified by CSIDL. The path is always returned in native format.

CSIDL must be one of the following symbols or the corresponding integer values values as defined in the Windows SDK: csidl_admintools, csidl_common_admintools, csidl_appdata, csidl_common_appdata, csidl_common_desktopdirectory, csidl_common_documents, csidl_common_favorites, csidl_common_music, csidl_common_pictures, csidl_common_programs, csidl_common_startmenu, csidl_common_startup, csidl_common_templates, csidl_common_video, csidl_cookies, csidl_desktopdirectory, csidl_favorites, csidl_history, csidl_internet_cache, csidl_local_appdata, csidl_mymusic, csidl_mypictures, csidl_myvideo, csidl_nethood, csidl_printhood, csidl_profile, csidl_profiles, csidl_programs, csidl_program_files, csidl_program_files_common, csidl_recent, csidl_sendto, csidl_startmenu, csidl_startup, csidl_system, csidl_templates, csidl_windows.

Refer to the documentation in the Windows SDK for the meaning of each of these identifiers.

If the option -create is specified, the folder will be created if it does not currently exist.

On some platforms, some of the above CSIDL's may be invalid. In this case, the command will attempt to return equivalent paths through other means such as environment variable settings.

The command will return an empty string if the CSIDL does not exist on the platform or if its value cannot be retrieved.
CloseThemeData
See Themes.
GetCurrentThemeName
See Themes.
GetThemeColor
See Themes.
GetThemeFont
See Themes.
invoke_url_shortcut SHORTCUTPATH ?options?
Invokes a URL shortcut. SHORTCUTPATH specifies the path of the URL shortcut itself. The following options may be specified.
-allowui Allows user interaction.
-hwin HWIN Specifies the parent window handle for user interaction. This is ignored if -verb is specified or if -allowui is not specified.
-verb VERB Specifies the verb to invoke on the shortcut, for example open, edit etc.
IsAppThemed
See Themes.
IsThemeActive
See Themes.
OpenThemeData
See Themes.
read_shortcut SHORTCUTPATH ?options?
Reads a shortcut. SHORTCUTPATH specifies the path of the shortcut itself. The contents of the shortcut are returned as a keyed list with the following fields.
-args Command line arguments for the link.
-desc Description of the shortcut. This is the string that is visible to the user as the label of the shortcut.
-hotkey The hotkey associated with the shortcut. This is an integer as described in the documentation of the IShellLink::Hotkey command in the Platform SDK.
-iconindex The index of the icon within the icon file specifies by the -iconpath field.
-iconpath The path to the file from which the icon for the shortcut is to be taken.
-idl The item identifier list for the object pointed to by the shortcut.
-path The file system path in the case that the shortcut points to a file.
-showcmd The initial state of the window.
-workdir The working directory of the shortcut.
Note that the field names are the same as the options for the write_shortcut command so you can modify a shortcut by reading it, changing the specific fields and passing the same list to write_shortcut.

The content format and operation of the command may be controlled through the following options.
-hwin HWIN Identifies the window to be used as the parent of the dialog box that pops up to ask the user for more information when the shortcut cannot be resolved.
-install Calls the MSI installer if the shortcut is an advertised shortcut and the target has not been installed yet.
-nolinkinfo Disables distributed link tracking.
-nosearch Normally, the command will search for the target if it cannot be found in the location pointed to by the shortcut. Specifying this option disables this search.
-notrack Specifies that distributed link tracking to be not used.
-noui Specifies that no dialog box should be displayed even if the link cannot be resolved.
-rawpath Normally, the command resolves any embedded environment variables contained in the returned -path field and verifies the path exists. Specifying this option disables both these features and returns raw path contained in the shortcut.
-shortnames The path contained in the returned -path field uses short name (8.3) format.
-timeout TIMEOUT Specifies the timeout, in milliseconds, for resolving the link. This option has no effect unless the -noui is also specified.
-uncpath The path contained in the returned -path field is in UNC format.
read_url_shortcut SHORTCUTPATH
Returns the URL pointed to by a URL shortcut. SHORTCUTPATH specifies the path of the URL shortcut itself.
recycle_file FILENAME ?-confirm BOOLEAN? ?-showerror BOOLEAN?
Sends the specified file to the Windows Recycle Bin. Returns true on success and false if user aborted the command. Any errors will generate a Tcl exception.
-confirm BOOLEAN If true, a confirmation dialog is displayed to the user. Default is false.
-showerror BOOLEAN If true, an error dialog is displayed to the user in case of errors. Default is false.
shell_object_properties_dialog OBJECTPATH ?options?
Displays the shell property dialog for the specified object which may be a file, a printer or a volume. OBJECTPATH is the path or the name of the object. The following options may be specified:
-hwin HWIN If specified, HWIN is the handle to the window to be used as the parent for the dialog.
-page PAGENAME Specifies the name of the property sheet page to be displayed. If unspecified, the default page is displayed.
-type file|printer|volume Specifies the type of the object identified by OBJECTPATH. If this option is not specified, the command will attempt to figure out the object type and display the appropriate dialog.
write_shortcut SHORTCUTPATH ?options?
Writes or creates a shortcut. SHORTCUTPATH specifies the path of the shortcut itself. The following options control the contents of the shortcut.
-args ARGUMENTS Specifies the command line arguments for the link.
-desc DESCRIPTION Specifies the description of the shortcut. This is the string that is visible to the user as the label of the shortcut.
-hotkey HOTKEY Specifies the hotkey to be associated with the shortcut. HOTKEY should be an integer as described in the documentation of the IShellLink::Hotkey command in the Platform SDK or a symbolic string as described in the register_hotkey command.
-iconindex INDEX Specifies INDEX as the index of the icon within the icon file specifies by the -iconpath option.
-iconpath ICONPATH Specifies ICONPATH as the path to the file from which the icon for the shortcut is to be taken.
-idl IDL Specifies that the shortcut should point to the object identified by the item identifier list IDL. This is useful in cases where the target of the short cut is not a file.
-path TARGETPATH Specifies TARGETPATH as the file system path that the shortcut to which the shortcut points.
-showcmd WINDOWSTATE Specifies the initial state of the window. WINDOWSTATE should be one of minimized, maximized or normal.
-workdir DIRPATH Specifies DIRPATH as the working directory of the shortcut.
write_url_shortcut SHORTCUTPATH URL ?-missingprotocol usedefault|guess?
Writes or creates a URL shortcut. SHORTCUTPATH specifies the path of the URL shortcut itself. URL is the URL to which the shortcut should point.

If the -missingprotocol option is specified, the system will attempt to fill in the protocol if URL itself does not specify a protocol. If the value of this option is guess, the system will attempt to guess the protocol based on the URL string. If the option value is usedefault, the system will use the default protocol scheme.

COPYRIGHT

Copyright © 2004-2006 Ashok P. Nadkarni

Tcl Windows API 2.1.6 Privacy policy