Rediger

Del via


Internet Shortcuts

The Internet shortcut object is used to create desktop shortcuts to Internet sites. Like shortcuts to items in the file system, Internet shortcuts take the form of an icon on the desktop. When the user clicks the icon, the browser is launched and displays the site associated with the shortcut.

The following topics are discussed.

Creating Internet Shortcuts

You can create an Internet shortcut by using a WebBrowser control or with the URL of the page.

Creating an Internet Shortcut from a WebBrowser Control

If your application hosts a WebBrowser control, you can use the Internet shortcut object to create shortcuts in the following way.

  1. Create an instance of the Internet shortcut object with CoCreateInstance, using a class identifier (CLSID) of CLSID_InternetShortcut.
  2. Pass the pointer to the WebBrowser's IUnknown interface to the Internet shortcut object with IObjectWithSite::SetSite.
  3. Call the Internet shortcut object's IPersistFile::Save method when you want to create a shortcut to the page being viewed by the WebBrowser control.

A shortcut will be created in the location specified in IPersistFile::Save. This location enables the WebBrowser control to restore its state, which includes the task of loading of the correct documents into framesets.

Creating an Internet Shortcut from a URL

You can also create an Internet shortcut if you have the URL of the page to which you want to link.

  1. Create an instance of the Internet shortcut object with CoCreateInstance, using a CLSID of CLSID_InternetShortcut.
  2. Use the IUniformResourceLocator::SetURL method to set the URL in the shortcut.
  3. Use the IPersistFile::Save method to save the shortcut file to a desired location.

Accessing Property Storage

The Internet shortcut object contains several properties that you can access through the object's IPropertySetStorage interface with the following procedure.

  1. Get the IPropertySetStorage interface by calling QueryInterface with IID_IPropertySetStorage.
  2. Access the Internet shortcut property storage set by calling IPropertySetStorage::Open with FMTID_Intshcut or FMTID_InternetSite to obtain the IPropertyStorage interface.
  3. Read the property storage information with IPropertyStorage::ReadMultiple by passing the appropriate property ID.

With version 4.70 or higher of Shell32.dll, you can also retrieve the IPropertySetStorage interface by calling IShellFolder::BindToStorage with the pidl parameter set to the .URL file and the riid parameter set to IID_IPropertySetStorage.

The following property IDs can be requested for FMTID_Intshcut.

PROPID Variant Type Description
PID_IS_URL VT_LPWSTR URL to which the shortcut leads
PID_IS_NAME VT_LPWSTR Name of the Internet shortcut
PID_IS_WORKINGDIR VT_LPWSTR Working directory for the shortcut
PID_IS_HOTKEY VT_UI2 Hotkey for the shortcut
PID_IS_SHOWCMD VT_I4 Show command for shortcut
PID_IS_ICONINDEX VT_I4 Index of the icon
PID_IS_ICONFILE VT_LPWSTR File that contains the icon
PID_IS_WHATSNEW VT_LPWSTR What's New text
PID_IS_AUTHOR VT_LPWSTR Author
PID_IS_DESCRIPTION VT_LPWSTR Description text of site
PID_IS_COMMENT VT_LPWSTR User annotated comment
PID_IS_ROAMED VT_BOOL True when shortcut is roamed for first time

 

The following property IDs can be requested for FMTID_InternetSite.

PROPID Variant Type Description
PID_INTSITE_WHATSNEW VT_LPWSTR What's New text
PID_INTSITE_AUTHOR VT_LPWSTR Author
PID_INTSITE_LASTVISIT VT_FILETIME Time site was last visited
PID_INTSITE_LASTMOD VT_FILETIME Time site was last modified
PID_INTSITE_VISITCOUNT VT_UI4 Number of times user has visited
PID_INTSITE_DESCRIPTION VT_LPWSTR Description text of site
PID_INTSITE_COMMENT VT_LPWSTR User annotated comment
PID_INTSITE_FLAGS VT_UI4 Indicates use of PIDISF_ flags (see below)
PID_INTSITE_CONTENTLEN N/A Not currently supported
PID_INTSITE_CONTENTCODE N/A Not currently supported
PID_INTSITE_RECURSE N/A Not currently supported
PID_INTSITE_WATCH N/A Not currently supported
PID_INTSITE_SUBSCRIPTION VT_UI8 SUBSCRIPTIONCOOKIE value for subscription manager
PID_INTSITE_URL VT_LPWSTR URL to which the shortcut leads
PID_INTSITE_TITLE VT_LPWSTR Title
PID_INTSITE_CODEPAGE VT_UI4 Codepage of the document
PID_INTSITE_TRACKING N/A Not currently supported
PID_INTSITE_ICONINDEX VT_I4 Index of the icon
PID_INTSITE_ICONFILE VT_LPWSTR File that contains the icon
PID_INTSITE_ROAMED VT_UI4 The entry was added due to roaming

 

The following are the Internet site flags.

Flag Description
PIDISF_RECENTLYCHANGED Indicates that a site was recently changed
PIDISF_CACHEDSTICKY Not currently supported
PIDISF_CACHEIMAGES Not currently supported
PIDISF_FOLLOWALLLINKS Not currently supported

 

The following values are used for Internet roaming history.

Value of PID_INTSITE_ROAMED Description
Value not set or PIDISR_UP_TO_DATE This cache entry has not been modified by roaming.
PIDISR_NEEDS_ADD This cache entry was added to the cache by roaming. Set PIDISR_UP_TO_DATE once processing of the entry is complete.
PIDISR_NEEDS_UPDATE This cache entry already existed on the local machine, but it was updated by roaming. Set PIDISR_UP_TO_DATE once processing of the entry is complete.
PIDISR_NEEDS_DELETE Roaming detected that this cache entry should be deleted. For example, the user may have cleared his or her browser history. Delete the entry using DeleteUrlCacheEntry.

 

Interfaces

The Internet shortcut object exposes a number of interfaces.

OLE interfaces

Shell interfaces

Functions

There are several utility functions that can be used with the Internet shortcut object.

Internet shortcut utility functions