Storages & Files SFShellLink object
See also object creation information - ClassID/ProgID 

Members references

This object allows the program to manage shell shortcuts - create, modify them etc. The shell shortcuts are special small files used by the Windows Explorer to present the user with nice looking UI that allows him to start programs, open documents and URL. In general the shortcuts are used in many different ways:

  • As Icons on the desktop
  • As Items in the Start menu
  • As Items in many other menus such as: Favorites, Send To, Recent documents etc.

Usually the shortcuts are stored in certain directories on the hard drive and Windows Explorer creates the menus and the other UI presentations dynamically by reading the directory contents. These directories are pre-defined by the system and the application can query them through the SFMain.GetSpecialPath.

Some other applications (not supplied with the Windows OS itself) may use shortcuts as well. In most cases this is done for compatibility reasons - for example bookmark (Favorites) organization applications. However using the system defined shortcuts is a good idea even if no particular compatibility is intended. This will allow the user to use the standard copy file operations to copy these shortcuts to another location or import them in a Windows Explorer supported UI (Start menu, favorites etc.).

There are two different shortcut types - Local and Internet (URL) shortcuts. They are stored in different formats and thus they are not binary compatible! The local shortcuts are stored in binary form while the Internet shortcuts are stored in INI file format. Also some of the settings are ignored for all of the internet shortcuts and for the local shortcuts which point non-application targets. If the target of the shortcut is a document the shell extension association is used to open the document.

Terms. Target of the shortcut is the main application, URL or document pointed by the shortcut. In other words this is the main field. The Name, FileName and Path terms are used in this document to characterize the shortcut file itself. This separation is more convenient than the typical full physical file name because usually the applications will want to create more than one shortcut in the same directory. So the application sets the Path property and then using the Name (or the FileName property if non-standard file extension is to be used) property defines the shortcut name. The shortcut file name is displayed in the Windows Explorer UI elements so it is important and should be short but enough informative.

Rules: By default all the shortcuts use two file extensions (not visible for the user) - .lnk for the local shortcuts and .url for the Internet shortcuts. Setting the shortcut type will automatically set the appropriate file extension during a Save operation. So the Name property is supposed to contain the file name only - without extension. In other cases if the application wants to use non standard extension the FileName property can be used to specify the file name with the extension (such technique is used rarely). So, in the most cases the application will not need to care about the file extension.

Remarks

The object uses the Windows Shell supplied interfaces. Because of their implementation specifics some limitations apply. The local shortcuts will not be a problem for any application running under any circumstances. On contrary the Internet (URL) shortcuts will fail if the SFShellLink object is not created in single threaded COM apartment! To avoid the problem you can use the COMApartment object. We are able to re-implement the Internet shortcut management functionality and in fact it is quite simple (as it is an INI file) but this may cause future compatibility problems if Microsoft decide to change their format. Therefore we decided to leave the things as they are now even if the limitations are the price.

Member reference

  Name Applicable if Target is Description
Program Document URL
Name - - - Name of the shortcut (without file extension)
FileName - - - File name (without path) for the shortcut's file
InternetShortcut - - - Is the shortcut a link to an URL or a local target*
Path - - - Directory where the shortcut is to be saved to or opened from
Arguments Yes No No

Arguments passed to the program pointed by the shortcut

Target - - - Target of the shortcut - the actual file/URL pointed by it.
Description Yes Yes Yes Description of the shortcut (shown as tool-tip by the Windows shell)
HotKey Yes Yes Yes A hot-key code for the shortcut
IconPath Yes Yes Yes Path to the file containing icon(s).

IconIndex

Yes Yes Yes Icon index to use from the icon source.
ShowCmd Yes Yes Yes Initial application window presence.
WorkingDirectory Yes No No The working directory for the application.
Open - - - Opens a shortcut's file
Save - - - Saves the shortcut to the disk.
ReadFromStream - - - Read the shortcut data from a stream.
WriteToStream - - - Write the shortcut data to a stream.
Clear - - - Clear the currently contained information in the object.
Delete - - - Delete the shortcut's file.
Resolve - - - Not implemented

Supported on:

Windows 95/NT and later
Not supported on Windows CE/Pocket PC

newObjects Copyright 2001-2006 newObjects [ ]