IShellLinkW::SetRelativePath method (shobjidl_core.h)
Sets the relative path to the Shell link object.
Syntax
HRESULT SetRelativePath(
LPCWSTR pszPathRel,
DWORD dwReserved
);
Parameters
pszPathRel
Type: LPCTSTR
The address of a buffer that contains the fully-qualified path of the shortcut file, relative to which the shortcut resolution should be performed. It should be a file name, not a folder name.
dwReserved
Type: DWORD
Reserved. Set this parameter to zero.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
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:\.
::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);
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | shobjidl_core.h |
DLL | Shell32.dll (version 4.0 or later) |
See also
IShellLinkA
IShellLinkW