Shortcut target changed!?

D

Don Wiss

Our users have shortcuts on their desktops that open a folder on the public
drive. The folder name includes the year. Each year we create an updated
folder for the next year. We then rename the old folder, by adding "-old"
to the end. Our intent is to break any shortcuts, forcing them to create a
new shortcut to the current year. But, lo and behold, I found that if you
click the shortcut to the renamed folder it finds the renamed folder and
then changes the target in the shortcut properties! So we have not broken
the shortcuts as we intended. How does it do this? If we stuck the OLD in
the middle of the folder name would we really break it? Or how can we break
them?

Don <www.donwiss.com> (e-mail link at home page bottom).
 
D

David Candy

It's not done just by name. It has other means to track users breaking their shortcuts (NTFS only). If all else fails it searches using dates (and sizes if relevent) as it main way to find renamed items.

Users don't like broken shortcuts.
 
D

David Candy

This is the programming docs on the Resolve function (what explorer uses).

IShellLink::Resolve Method

--------------------------------------------------------------------------------

Attempts to find the target of a Shell link, even if it has been moved or renamed.

Syntax

HRESULT Resolve( HWND hwnd,
DWORD fFlags
);Parameters

hwnd
Handle to the window that the Shell will use as the parent for a dialog box. The Shell displays the dialog box if it needs to prompt the user for more information while resolving a Shell link.
fFlags
Action flags. This parameter can be a combination of the following values.
SLR_INVOKE_MSI
Call the Microsoft® Windows® Installer.
SLR_NOLINKINFO
Disable distributed link tracking. By default, distributed link tracking tracks removable media across multiple devices based on the volume name. It also uses the Universal Naming Convention (UNC) path to track remote file systems whose drive letter has changed. Setting SLR_NOLINKINFO disables both types of tracking.
SLR_NO_UI
Do not display a dialog box if the link cannot be resolved. When SLR_NO_UI is set, the high-order word of fFlags can be set to a time-out value that specifies the maximum amount of time to be spent resolving the link. The function returns if the link cannot be resolved within the time-out duration. If the high-order word is set to zero, the time-out duration will be set to the default value of 3,000 milliseconds (3 seconds). To specify a value, set the high word of fFlags to the desired time-out duration, in milliseconds.
SLR_NOUPDATE
Do not update the link information.
SLR_NOSEARCH
Do not execute the search heuristics.
SLR_NOTRACK
Do not use distributed link tracking.
SLR_UPDATE
If the link object has changed, update its path and list of identifiers. If SLR_UPDATE is set, you do not need to call IPersistFile::IsDirty to determine whether or not the link object has changed.
Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

Following link creation, the name or location of the target may change. The IShellLink::Resolve method first retrieves the path associated with the link. If the object is no longer there or has been renamed, Resolve will attempt to find it. If successful, and the following conditions are met, the file that the link object was loaded from will be updated to reflect the new state of the link object.


a.. The SLR_UPDATE flag is set.
b.. The target has been moved or renamed, updating the internal state of the Shell link object to refer to the new target.
c.. The Shell link object was loaded from a file through IPersistFile.

The client can also call the IPersistFile::IsDirty method to determine whether the link object has changed and the file needs to be updated.

Resolve has two approaches to finding target objects. The first is the distributed link tracking service. If the service is available, it can find an object that was on an NTFS version 5.0 volume and was moved to another location on that volume. It can also find an object that was moved to another NTFS version 5.0 volume, including volumes on other computers. To suppress the use of this service, set the SLR_NOTRACK flag.

If distributed link tracking is not available or fails to find the link object, Resolve attempts to find it with search heuristics. It first looks in the object's last known directory for an object with a different name but the same attributes and file creation time. Next, it recursively searches subdirectories in the vicinity of the object's last known directory. It looks for an object with the same name or creation time. Finally, Resolve looks for a matching object on the desktop and other local volumes. To suppress the use of the search heuristics, set the SLR_NOSEARCH flag.

If both approaches fail, the system will display a dialog box prompting the user for a location. To suppress the dialog box, set the SLR_NO_UI flag.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top