Sets the relative path to the Shell link object.
Syntax
HRESULT SetRelativePath(
LPCTSTR pszPathRel,
DWORD dwReserved
);
Parameters
- pszPathRel
-
The address of a buffer that contains the new relative path. It should be a file name, not a folder name.
- dwReserved
-
Reserved. Set this parameter to zero.
Return Value
Returns S_OK if successful, or an error value otherwise.
Remarks
Clients commonly define a relative link when it may be moved along with its target, causing the absolute path to become invalid. The SetRelativePath method can be used to help the link resolution process find its target based on a common path prefix between the target and the relative path. To assist in the resolution process, clients should set the relative path as part of the link creation process.
Examples
Consider the following scenario:
- You have a link: c:\MyLink.lnk.
- The link target is c:\MyDocs\MyFile.txt.
- You want to move the link and MyDocs\MyFile.txt to d:\.
You can assist the resolution process by creating the original link with a relative path before the shortcut is saved.
::SetRelativePath("c:\MyLink.lnk", NULL);
Before the shortcut is resolved, set a new relative path, and the Resolve code will find the file in its new location.
::SetRelativePath("d:\MyLink.lnk", NULL);
See Also